[英]FB Graph API posting to the wall of one of my pages
我不明白FB'API是否非常愚蠢,或者我的API感知不適合這樣做。 我的目標很簡單。 我有一個CMS。 當我從CMS的管理頁面創建新聞時,我也想將其發布到我的Facebook頁面。 這個API惹惱了我! 這是我的代碼;
$s = FacebookSession::setDefaultApplication('appid', 'secret');
$session = FacebookSession::newAppSession();
// when I use belowed two line, I'm getting error
//$request = new FacebookRequest($session, 'GET', '/me');
//$pageList = $request->execute()->getGraphObject()->asArray();
$session = new FacebookSession('I don't know what to write here? I have a session already? When I use the access token which taken from api explorer page, due to it's life is short, I'm getting also error.');
$page_post=(new FacebookRequest( $session, 'POST','/<my_page_id_not_my_profile_id>/feed', array(
'access_token' => 'die!!! one more token! what is this!',
'link' => 'link',
'message' => 'message', ) ))->execute()->getGraphObject()->asArray();
注意:我不希望彈出窗口登錄或任何其他方法。 我只希望一個純真的API像Twitter的一樣甜蜜地使用...
Facebook API的工作原理與Twitter非常相似。 您也不能僅在Twitter上僅發布一個應用會話,還需要授權用戶。
由於Facebook上有用戶個人資料和頁面,因此有用戶訪問令牌和頁面訪問令牌。 您需要的是頁面訪問令牌,然后通過授權用戶使用您的應用程序來獲取用戶令牌並調用/me/accounts
端點以獲取您管理的所有頁面的頁面令牌,從而獲得一個頁面訪問令牌。 另外,您需要使用publish_actions
和manage_pages
權限授權用戶。 之后,您可以使用帶有該頁面令牌的/page-id/feed
終結點“作為頁面”發布到頁面牆。
這是有關訪問令牌的更多信息,您需要的是永久存在的“擴展頁面令牌”:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.