How can I find out what Page has installed my Facebook App / which page is loading my app

前端 未结 1 432
夕颜
夕颜 2020-12-10 08:49

I have a canvas app (http://apps.facebook.com/myapp) and other pages (businesses, etc) can Add it to their page. Within my app, how can I know which page I\'m being called f

1条回答
  •  心在旅途
    2020-12-10 09:40

    As documented in Facebook Page Tab Tutorial:

    When a user navigates to the Facebook Page, they will see your Page Tab added in the next available tab position. Broadly, a Page Tab is loaded in exactly the same way as a Canvas Page. When a user selects your Page Tab, you will received the signed_request parameter with one additional parameter, page. This parameter contains a JSON object with an id (the page id of the current page), admin (if the user is a admin of the page), and liked (if the user has liked the page). As with a Canvas Page, you will not receive all the user information accessible to your app in the signed_request until the user authorizes your app.

    So one way to capture the page id would be:

     'APP_ID',
      'secret' => 'APP_SECRET',
      'cookie' => true,
    ));
    $signed_request = $facebook->getSignedRequest();
    if( $page = $signed_request['page'] ) {
        echo $page['id'];
    }
    ?>
    

    OR a solution without the PHP-SDK:

    0 讨论(0)
提交回复
热议问题