问题
I am trying to download a Facebook discussion using the graph API. The problem is: the discussion is located in a page, and in a tree-style manner, meaning that there are two types of comments: "main" comments, to the first message, and "subcomments" to the main comments themselves.
It seems that the graph result only shows the "main" comments and doesn't show the subcomments. Here's an example of a comment it returns:
{
"id": "53526364352_1574091",
"can_remove": false,
"created_time": "2014-02-05T10:46:37+0000",
"from": {
"name": "Main commenter",
"id": "5345353"
},
"like_count": 163,
"message": "I am a main comment",
"user_likes": false
},
There is no link or whatever to the subcomments of this main comment (and there are many).
Is there a way to get the subcomments?
回答1:
If 10101140614002197_8831228
is an ID of a root comment, then you can check for subcomments/replies by requesting COMMENT_ID/comments
.
For example:
- the root comment: http://graph.facebook.com/10101140614002197_8831228
- the subcomment: http://graph.facebook.com/10101140614002197_8831228/comments
- this root comment has no subcomments so the
data
list is empty: https://graph.facebook.com/10101140614002197_8831286/comments
回答2:
You can use field expansion (curly parenthesis in url) to get nested data
http://graph.facebook.com/{object-id}/comments?fields=id,message,comments{id,message,comments{id,message,comments}}
More info here in the section labeled Nested requests (a.k.a. field expansion)
.
来源:https://stackoverflow.com/questions/22280955/facebook-graph-api-get-the-subcomments-in-a-tree-of-a-discussion