如果是,重定向到另一个页面,如何检查用户是否喜欢Facebook页面?

I would like to create a PHP script to check if the user 'Like's the page. If the user likes the page he is redirected to another URL if not the User is asked to like the page and the facebook like button appears so the user can like.

How can this be done please? I managed to get hold of this script and got errors. Any help please?

Thanks

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Facebook "If-Like" Application | ThreeDots</title>
    </head>
    <body>
    <?php
        include_once( "facebook.php" );

        $fbAppArray = array(
            'appId'  => 'YOUR_APPLICATION_ID',
            'secert' => 'YOUR_APPLICATION_SECRET',
            'cookie' => true
        );

        $fbAppObj = new Facebook( $fbAppArray );

        $signedRequest = $fbAppObj->getSignedRequest();

        function parsePageSignedRequest()
        {
            if( isset( $_REQUEST['signed_request'] ) )
            {
                $encoded_sig = null;
                $payload = null;

                list( $encoded_sig, $payload ) = explode( '.', $_REQUEST['signed_request'], 2 );

                $sig = base64_decode( strtr( $encoded_sig, '-_', '+/' ) );
                $data = json_decode( base64_decode( strtr( $payload, '-_', '+/' ), true ) );

                return $data;
            }

            return false;
        }

        if( $signedRequest = parsePageSignedRequest() )
        {
            if( $signedRequest->page->liked )
            {
                // What to show the user if he liked the application...
            }else{
                // Please like the application so you will be able to see the contents...
            }
        }
    ?>
    </body>
</html>

The signed_request parameter is only available if your app is running as canvas app or page tab app inside of Facebook. If that’s the case, please read up on this parameter and how to interpret it in the docs.

(Btw., just saying “I get errors” is neither a helpful nor a smart way of describing a programming related problem. So please read http://facebook.stackoverflow.com/questions/how-to-ask as well.)

If your app is not running inside Facebook, then you have to have the user connect to your app, get his permission to read his likes, and look for yourself if your specific page is amongst them. For all that, please refer to documentation as well.