0
我使用的是PHP SDK 3.0,我想在管理員的粉絲頁面上發佈流。我使用一些代碼象下面這樣,所有的工作樂趣,但流後不會發布作爲管理員用戶,但風機用戶()發佈到Facebook粉絲頁作爲管理員使用PHP
登錄請求
$fb = new Facebook(array( 'appId' => $pluginParams->get('ApplicationKey'),
'secret' => $pluginParams->get('Secret'),
'cookie' => true
)) ;
.......
$loginUrl = $fb->getLoginUrl(array('scope' => 'manage_pages,offline_access,publish_stream, read_stream'));
的部分代碼發送流的
$body['id'] = $pluginParams->get('YourFanpageID');
$body['message']=$message;
$body['picture']=$image;
$body['caption']=$item->title;
....
$AccessToken= $this->get_page_access_token($pluginParams->get('YourFanpageID'), $pluginParams->get('AccessToken'), $pluginParams->def('UserID',$me['id']));
......
$body = http_build_query($body);
$body = urldecode($body);
$request = array(
'method' => 'POST',
'relative_url' => 'feed',
'body' => $body
);
$batch[] = $request;
$params = array(
'access_token' => $AccessToken,
'batch' => json_encode($batch)
);
$result=$fb->api('/', 'POST', $params);
函數來獲得訪問令牌頁
function get_page_access_token($page_id, $access_token, $user_id) {
$data = file_get_contents('https://graph.beta.facebook.com/'.$user_id.'/accounts?access_token='.$access_token);
$pages = json_decode($data,true);
foreach($pages['data'] as $page) {
if($page['id'] == $page_id) {
return $page['access_token'];
}
}
}
你能告訴請,如果日ere是要添加的代碼以告訴頁面這是管理員發佈的內容嗎?
發佈到Facebook粉絲頁作爲管理員使用PHP?