加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

如何通过API(Php SDK)以管理员身份发布到Facebook页面?

发布时间:2020-12-13 18:08:25 所属栏目:PHP教程 来源:网络整理
导读:我知道如何使用 PHP SDK通过API发布到Facebook页面的帖子,如下所示: $facebook-api('/xxxxxxxxxxx/feed','post',array('message'= 'Hello world!','cb' = '')); 其中xxxxxxxxxxx是页面ID;) 但是这样做,我作为我发布到那个页面,杰米,而不是作为页面本身(管理
我知道如何使用 PHP SDK通过API发布到Facebook页面的帖子,如下所示:
$facebook->api('/xxxxxxxxxxx/feed','post',array('message'=> 'Hello world!','cb' => ''));

其中xxxxxxxxxxx是页面ID;)

但是这样做,我作为我发布到那个页面,杰米,而不是作为页面本身(管理员).
那么如何以Admin / Page而不是我自己的身份发布?

谢谢你的时间!

答案(对于懒人):

首先,您需要确保您有权管理用户的页面,例如:

<fb:login-button autologoutlink="true" perms="manage_pages"></fb:login-button>

现在,您还可以获取每个用户访问后可访问的页面的特殊标记.
PHP SDK示例:

//Get pages user id admin for
$fb_accounts = $facebook->api('/me/accounts');
//$fb_accounts is now an array 
//holding all data on the pages user is admin for,//we are interested in access_token 

//We save the token for one of the pages into a variable 
$access_token = $fb_accounts['data'][0]['access_token'];

//We can now update a Page as Admin
$facebook->api('/PAGE_ID/feed',array('message'=> 'Hello!','access_token' => $access_token,'cb' => ''));
查看有关您的问题的此说明: http://developers.facebook.com/docs/api>授权>页面模仿.

简而言之,您需要manage_pages扩展权限.

顺便说一句,你先检查过this吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读