Get (Identify) Replies to Comments Using the Graph API

梦想的初衷 提交于 2019-12-18 04:50:37

问题


With the new "Reply" to "Comments" feature on Facebook, I've noticed that replies to comments are treated the same as comments. But I was wondering if there is anyway to distinguish the two?


回答1:


Yes. You can query each comment object in the Graph API for the value of its parent field. If the comment in question is a reply, then the value of the parent field will be a reference to the parent comment. Otherwise, no value is returned.

Reference here: https://developers.facebook.com/docs/reference/api/Comment/




回答2:


You first have to enable July Breaking Changes from your app advanced settings

Then use the fields parameter with the comments graph API and include the parent.field(id) column with the and also the filter parameter with the stream value. the final result :

{POST_ID}/comments?filter=stream&fields=parent.fields(id),message,from,likes

this should return both comments and replies with the parent element which has the comment id that the reply belongs to

-- update

and for better array arrangement for replies you can use the following to merge replies with the actual comment array you can include comments.summary(true) in the fields parameter

{POST_ID}/comments?limit=0&filter=toplevel&fields=comments.summary(true),message,from,likes

filter parameter is optional

for more info about the fields : http://developers.facebook.com/docs/reference/api/Comment/

and in case you want to do it in FQL, check this post's comments http://developers.facebook.com/blog/post/2013/04/03/new-apis-for-comment-replies/




回答3:


You can get comment replies in this way.

/{{POST_ID}}/?fields=comments{comments}&access_token={{ACCESS_TOKEN}}

You can get any sub info(from,id) of comment replies by just nesting fields inside comments like this:

/{{POST_ID}}/?fields=comments{comments,from,id}&access_token={{ACCESS_TOKEN}}

Similar post over here : https://stackoverflow.com/a/37743410/6001533




回答4:


If you're listening for comments on the 'feed' webhook, you should check if:

entry[0][changes][0][value][post_id] === entry[0][changes][0][value][parent_id]

This will be true for top-level (new) comments, and false for replies to comments.




回答5:


To piggy back off @sujit's answer I took his answer and in one call from the feed you can get the entire feed, comments and replies to comments as well as associated images to those comments and replies in one shot.

Here is the code

https://graph.facebook.com/$get_facebook/feed?access_token=$facebook_accesstoken&client_id=$facebook_appid&client_secret=$facebook_appsecret&metadata=1&fields=id,status_type,created_time,from,message,comments{comments{attachment,from,id,message},from,id,message,attachment},picture,link,icon


来源:https://stackoverflow.com/questions/15795133/get-identify-replies-to-comments-using-the-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!