2

As I knew there is a way to get access token via https://developers.facebook.com/tools/explorer.

Is there other way to get page_access_token by API?

I want to post request to add app to facebook page but it require a page_access_token as below:

https://graph.facebook.com/myPageId/tabs/?app_id=myAppId&access_token=myPageAccessToken

Thanks.

1 Answer 1

1

Yes you can. The current user must be an administrator of this page;

extended permission needed - manage_pages refer url: https://developers.facebook.com/docs/reference/api/page/

Try this:

$config = array(
'appId' => FB_APP_ID,
'secret' => FB_SECRET_KEY,
'cookie' => true // enable optional cookie support  
);
$facebook = new Facebook($config);

// See if there is a user from a cookie
$user = $facebook->getUser();

$params = array(
'scope' => 'manage_pages',
'redirect_uri' => FB_APP_URL,
);

$loginUrl = $facebook->getLoginUrl($params); 

<script> window.top.location.href = '<?php echo $loginUrl ?>';  </script>   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.