0

I am using the Facebook graph API to get the posts and the comments, and it's all working fine. Now I want to use the API to get the replies of a particular comment. How can I do that? I’m using the following code to get the comments:

cmmntObj = facebookClient.fetchObject(postID + "/comments", JsonObject.class,
                Parameter.with("limit", limitOfRecords),
                Parameter.with(Since_Until[k], date_SinceLast[k].toString()),
                Parameter.with("Date_Format", "U"));

The following code works well and fetches the comments. I would appreciate if somebody can help me in getting the replies also.

I parsed the Comments JSON and built another query around it but it doesn’t work. This is the query to fetch the tweets:

    String getCmmntID = new String();
        getCmmntID = cmmntObj.getJsonArray("data").getJsonObject(0).getString("id");// .getString("id");
        cmmntReplies = facebookClient.fetchObject(
            postID + "/comments?filter=stream&fields=parent.fields(" + getCmmntID + ")",
            JsonObject.class, Parameter.with("limit", limitOfRecords),
            Parameter.with(Since_Until[k], date_SinceLast[k].toString()),
            Parameter.with("Date_Format", "U"));

How do I get the replies to these?

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Aadil Khanday
  • 36
  • 1
  • 6

1 Answers1

0

It is possible to get the comments edge for your comments, and then to get the comments edge of those comments, ad-infinitum. This becomes a matter of you deciding how many levels of comments you want to code into your application. I'm not sure if there is a finite number of levels of comments that Facebook would allow, you'll have to experiment with that. However, here is what you would want to add:

Parameter.with("fields", "message,comments{comments,message}")

That will get you three levels of comments (the main comments and two levels of replies).

QuotidianVoid
  • 609
  • 5
  • 12