每个php和curl上的帖子上的“隐私价值”不起作用

时间:2011-11-22 11:54:06

标签: php facebook-graph-api curl

我希望在我的帖子墙上收到Curl和PHP。 我也把一切都搞清楚了,我是唯一能读懂它的人。 站在我设置参数" privacy"的纪录片中。必须设置{" value":" EVERYONE"}以便所有人都可以阅读该条目。 但是,这不起作用。我仍然是唯一一个。 我怎么能改变它?

$url = "https://graph.facebook.com/oauth/access_token";   
$client_id = "xxxxxxxxxxx";
$client_secret = "xxxxxxxxxxxxxxxxxxxxxx";
$postString = "client_id=$client_id&client_secret=$client_secret&type=client_cred";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FAILONERROR, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postString);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
$token = curl_exec($curl);
curl_close($curl);

$message = rawurlencode("Ich liebe hannaee");
$url = "https://api.facebook.com/method/stream.publish";
$apost = array("message"=>$message,"uid"=>xxxxxxxxxxxxxxx,"access_token"=>$token,"privacy"=>json_encode(array("value"=>"EVERYONE")));
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FAILONERROR, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $apost);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
$response = curl_exec($curl);
curl_close($curl);

1 个答案:

答案 0 :(得分:0)

根据http://developers.facebook.com/docs/reference/api/post/,您需要publish_stream权限(请参阅http://developers.facebook.com/docs/authentication/),您的应用程序不得处于沙盒模式。

更新:对Facebook Graph API - authorization types?的回答解释了为什么不应该使用 type = client_cred