试图用php和json从facebook上回复评论

时间:2014-03-27 10:00:40

标签: php json facebook facebook-php-sdk

我正在尝试使用php和json从facebook中提取公共页面来对收到的数据进行排序。除了对帖子的评论的回复之外,我的所有工作都完美无缺。我可以在帖子上获得所有评论列表,但对该评论的回复不会出现在返回给我的json数据上。我相信当页面的用户在他自己的帖子上发表评论时,评论会给出评论,并且与该帖子的评论部分无关。但如果有人回复评论,我无法在任何地方看到他们的消息。有没有办法尝试获取json中返回的注释的回复以及其他所有内容?

1 个答案:

答案 0 :(得分:0)

编辑:找到了更好的解决方案

请在此处查看答案:How to get the image from a facebook photo comment?

您要执行的查询是

/{page-post-id}/comments?fields=from,message,id,attachment,created_time,comments.fields(from,message,id,attachment,created_time)

通过PHP查询,你会做这样的事情:

$page_comment_id = 12345; // put your id here
$access_token = ''; // put your facebook access token here
$url = 'https://graph.facebook.com/' . $page_comment_id . '/comments?fields=from,message,id,attachment,created_time,comments.fields(from,message,id,attachment,created_time)&access_token=' . $access_token;
$data = json_decode(file_get_contents($url),true);
print_r($data);