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>   
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.