简体   繁体   中英

PHP - SDK - Facebook - Fan Page get the following data

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?

I tried using

`

// 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM