How to post to Facebookpage as admin via API (Php SDK)?(如何通过 API (Php SDK) 以管理员身份发布到 Facebookpage?)
问题描述
我知道如何使用 PHP SDK 通过 API 在 Facebook 页面上发帖,具体操作如下:
$facebook->api('/xxxxxxxxxxx/feed', 'post', array('message'=> 'Hello world!', 'cb' => ''));
其中 xxxxxxxxxxx 是页面 ID ;)
但这样做时,我以我自己的身份发布到该页面,杰米,而不是页面本身(管理员).
那么我如何以管理员/页面的身份而不是我自己的身份发帖?
But doing that, I post to that page as me, Jamie, and not as the Page itself (admin).
So how do I post as Admin/Page instead of myself?
感谢您的时间!
答案(针对懒人):
首先,您需要确保您有权管理用户的页面,例如:
First of all you need to make sure you have access to manage pages for user, ex:
<fb:login-button autologoutlink="true" perms="manage_pages"></fb:login-button>
现在,一旦您获得用户有权访问的每个页面,您还将获得一个特殊的令牌.
PHP SDK 示例:
Now you also gets a special token for every page user have access to once you get them.
PHP SDK Example:
//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', 'post', array('message'=> 'Hello!', 'access_token' => $access_token, 'cb' => ''));
推荐答案
查看关于您的问题的说明:http://developers.facebook.com/docs/api > 授权 > 页面模拟.
Check out this note regarding your question: http://developers.facebook.com/docs/api > Authorization > Page impersonation.
长话短说,您需要 manage_pages 扩展权限.
Long story short, you need the manage_pages extended permission.
顺便说一句,你有没有检查这个 首先?
And btw, have you checked this first ?
这篇关于如何通过 API (Php SDK) 以管理员身份发布到 Facebookpage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何通过 API (Php SDK) 以管理员身份发布到 Facebo
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
