Reputation: 5
have a question.
PHP SDK - facebook
How can I get the following data FanPage Name - FanPage ID - FanPage Token access -
of fanpages that I manage?
`
// Get the current access token
$access_token = $facebook->getAccessToken();
$accounts = $facebook->api('/me/accounts');
echo "Sobre Fan Pages: ";
print_r($accounts);
foreach ($accounts as $pub) {
foreach ($pub['data'] as $page) {
echo 'Pages: '.$page['name'].' '.$page['access_token'].' '.$page['id']."<br/>";
} }
` But $accounts only returns user data nothing about fanpages
What is wrong?
Upvotes: 0
Views: 960
Reputation: 728
I think you need to get a token that grants 'manage_pages' permissions. Look at https://developers.facebook.com/docs/reference/api/user/ (search the page for 'accounts' )
You need to redirect the user to a new login using the php sdk getLoginUrl($params) function, and specify as $params['scope'] a comma separated list of the permission you are requesting. Make sure manage_page is there. Then you get a new token that you can use to retrive the pages with /me/accounts.
HTH
Upvotes: 1