0
從一個教程在這裏:臉譜,通過PHP捲曲後評論
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
這不是我的應用程序acount牆上的帖子ID,我試圖給我的朋友牆,他允許我的應用程序,我可以發佈帖子到他的牆上,但在評論失敗,我得到了通過 https://graph.facebook.com/<his fid>/feed?access_token=140XXXXXXXXXXX
帖子ID,所以帖子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);
?>
感謝答覆,但仍retuen同樣錯誤的警告。 – cj333
是的,access_token是錯的 – genesis
你是對的,應該放一個完整的長access_token。我很困惑,當我發佈信息給朋友的牆時,只需要短的access_token,但評論需要更長的access_token。 – cj333