使用php oauth错误的Facebook墙报
这是我使用oauth在FACEBOOK墙上发布的代码使用php oauth错误的Facebook墙报,php,facebook,facebook-graph-api,curl,facebook-php-sdk,Php,Facebook,Facebook Graph Api,Curl,Facebook Php Sdk,这是我使用oauth在FACEBOOK墙上发布的代码 <?php class Facebook { /** * @var The page id to edit */ private $page_id = '559515220745012'; /** * @var the page access token given to the application above */ private $page_access_
<?php
class Facebook
{
/**
* @var The page id to edit
*/
private $page_id = '559515220745012';
/**
* @var the page access token given to the application above
*/
private $page_access_token = 'CAAFxzhxYP6kBAJZADenicftONfBf10ZBAv6uziZAUz4ZAlyOzIpkYZBtnonqarkih7TyT3N7kS3S6APvS80MWJRGjxgCGHjoZAapTZCqnJf8ltymJK27D8eG57cFqNQZBsCIu6xKdjXjHZBZCXQgB8hT0pIMfLoiHYJo7t9ZAXAZAVru7QZDZD';
/**
* @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
return $return;
}
}
$facebook = new Facebook();
$facebook->message(array( 'message' => 'The status header',
'link' => 'http://theurltopoint.to',
'picture' => 'http://thepicturetoinclude.jpg',
'name' => 'Name of the picture, shown just above it',
'description' => 'Full description explaining whether the header or the picture') );
echo "<pre>";
print_r($facebook->message());
echo "</pre>";
?>
我得到了一个类似这样的错误,{“error”:{“message”:(#100)缺少消息或附件”,“type”:“OAutheException”,“code”:100}
而且这根柱子也没有插进墙里。帮我解决这个问题
谢谢你错过了这一行:
不要公开您的访问令牌。人们可以用它发垃圾邮件。评论
print\r($facebook->message())代码>只需调用消息函数一次,工作正常。我检查了。我也试过了。还是一样。该消息未显示在Facebook墙中。请重试,以下代码正在运行:。替换PAGE\u ID
和TOKEN
代码现在工作正常。但是墙柱已经在我的帐户下显示了。我想在我的粉丝页面上展示这篇文章。让我们一起看吧
...
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
...