我正在尝试创建一个PHP应用程序,它将消息直接发布到FB页面。但在发布消息时遇到一些问题。我收到了以下错误: -
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
以下是我的代码: -
<?php
class Facebook
{
private $page_id = 'Page ID';
private $page_access_token = 'access-code';
private $post_url = '';
public function Facebook()
{
$this->post_url = 'https://graph.facebook.com/'.$this->page_id.'/feed';
}
public function message($data)
{
$data['access_token'] = $this->page_access_token;
$ch = curl_init();
echo "Link:- ".$this->post_url;
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);
$return = curl_exec($ch);
curl_close($ch);
return $return;
}
}
$facebook = new Facebook();
$facebook->message(array( 'message' => 'Best Service'));
?>
我尝试了很多来解决这个错误。我检查了访问令牌n页面ID也都正确但仍然出现此错误。
请指导我解决此错误....
提前致谢......