phpfacebook-graph-apifacebook-likefacebook-appsfacebook-canvas

About the like_status with PHP programming


When I try to use ['signed_request'] in PHP, I can't get [page][liked] / Page ID value. I only can get [algorithm], [issued_at], [user], [country], [locale], [age] values from ['signed_request'].

I have created "users_like" Permission in the App's Auth Dialog page. I have set up a Canvas page.

Please help me find out the problem and solution.

P.S. I want to set up a landing page which can check the user whether like it or not.


Solution

  • // create the Facebook Graph SDK object
    require_once('facebook.php');
    $facebook = new Facebook(array(
        'appId'=>'xxxxxxxx', // replace with your value
        'secret'=>'xxxxxxxx' // replace with your value
    ));
    $signedRequest = $facebook->getSignedRequest();
    
    // Inspect the signed request
    if($signedRequest['page']['liked'] == 1){ //Do your stuff here }
    

    That is all that's required, you don't need any permissions.

    EDIT: Also, make sure that you are actually trying to access a page, not, for example, an app canvas.