問題描述
我知道如何使用 PHP SDK 通過 API 在 Facebook 頁面上發(fā)帖,具體操作如下:
$facebook->api('/xxxxxxxxxxx/feed', 'post', array('message'=> 'Hello world!', 'cb' => ''));
其中 xxxxxxxxxxx 是頁面 ID ;)
但這樣做時,我以我自己的身份發(fā)布到該頁面,杰米,而不是頁面本身(管理員).
那么我如何以管理員/頁面的身份而不是我自己的身份發(fā)帖?
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?
感謝您的時間!
答案(針對懶人):
首先,您需要確保您有權(quán)管理用戶的頁面,例如:
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>
現(xiàn)在,一旦您獲得用戶有權(quán)訪問的每個頁面,您還將獲得一個特殊的令牌.
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' => ''));
推薦答案
查看關(guān)于您的問題的說明:http://developers.facebook.com/docs/api > 授權(quán) > 頁面模擬.
Check out this note regarding your question: http://developers.facebook.com/docs/api > Authorization > Page impersonation.
長話短說,您需要 manage_pages
擴展權(quán)限.
Long story short, you need the manage_pages
extended permission.
順便說一句,你有沒有檢查這個 首先?
And btw, have you checked this first ?
這篇關(guān)于如何通過 API (Php SDK) 以管理員身份發(fā)布到 Facebookpage?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!