1
我要做到以下幾點(簡單)的事情: - 寫消息發佈到頁面的飼料PHP類發佈到頁面的飼料 - 一切看起來正常,但後期不出現
我有創建了一個Facebook應用程序,獲得了以下操作授權令牌:
scope=publish_stream,offline_access,read_stream,manage_pages
一切似乎確定,該消息被適當方式公佈,返回的結果是一樣的東西:
{"id":"pageid_newmessageid"}
但是,該消息不會在指定頁面的牆上發佈。此外,當我嘗試訪問https://graph.facebook.com/pageid/feed?access_token=token此消息不存在。
任何想法爲什麼?
的PHP代碼:
<?php
class Facebook
{
/**
* @var The page id to edit
*/
private $page_id = 'pageid';
/**
* @var the page access token given to the application above
*/
private $page_access_token = 'token';
/**
* @var The back-end service for page's wall
*/
private $post_url = '';
/**
* Constructor, sets the url's
*/
public function Facebook()
{
$this->post_url = 'https://graph.facebook.com/' . $this->page_id . '/feed';
}
/**
* Manages the POST message to post an update on a page wall
*
* @param array $data
* @return string the back-end response
* @private
*/
public function message($data)
{
// need token
$data['access_token'] = $this->page_access_token;
// init
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// execute and close
$return = curl_exec($ch);
curl_close($ch);
// end
print_r($return);
return $return;
}
}
$facebook = new Facebook();
$facebook->message(array('message' => 'Some messag',
'link' => 'http://www.google.com',
'description' => 'Full description explaining whether the header'));
?>