【发布时间】:2011-11-09 01:49:53
【问题描述】:
从这里的一个教程:
Post a reply on a comment in Facebook using cURL PHP / Graph API
我试图在一个帖子后发表评论,但返回:
[type] => OAuthException [message] => (#200) The user hasn't authorized the application to perform this action
这不是我的应用帐户墙的帖子 ID,我尝试了我的朋友墙,他已允许我的应用,我可以在他的墙上发布帖子,但评论失败,我通过以下方式获得帖子 ID
https://graph.facebook.com/<his fid>/feed?access_token=140XXXXXXXXXXX,所以post id没有问题。
我错过了哪些步骤?
$fbId = '100001102789652_233997699980321';
$accessToken = '140XXXXXXXXXXXX';
$url = "https://graph.facebook.com/{$fbId}/comments";
$attachment = array(
'access_token' => $accessToken,
'message' => "Hi comment",
);
// set the target url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$comment = curl_exec($ch);
curl_close ($ch);
$comment = json_decode($comment, TRUE);
print_r($comment);
?>
【问题讨论】: