Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use 'manage_pages' permission with the SDK on Facebook?

I create an application which appears as a tab on fan page. The administrator of the fan page give me the permission manage_pages and then the tab of my application is added to his fan page.

The problem is that I didn't find any example code on how to use this permission with the PHP SDK. I looked in the file base_facebook.php of the SDK, and I guess that I should using the function getApiUrl, but I'm not sure and probably I don't know how using this function.

like image 564
Luis Avatar asked Dec 09 '25 20:12

Luis


1 Answers

Now that you have the manage_pages permission, take the access token, pass it into a method like the one I've created below to get an access token to manage the page. Each page has its own access token that you need to use once you have the manage_pages permission.

function get_page_access_token($page_id, $access_token, $user_id) {
    $data = file_get_contents('https://graph.beta.facebook.com/'.$user_id.'/accounts?access_token='.$access_token);
    $pages = json_decode($data,true);
    foreach($pages['data'] as $page) {
      if($page['id'] == $page_id) {
        return $page['access_token']; 
      }   
   }
}
like image 62
Jeff Sherlock Avatar answered Dec 12 '25 09:12

Jeff Sherlock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!