-1

I am trying to grab reply to certain comment from facebook using the help from the comment library of restfb and the function getcomments().

After executing my code, it returns me a null rather than a reply to the comment.

Below is my snapshot of my code.

Connection<Comment> allComments = fbClient.fetchConnection(myArr1.get(xy)+"/comments", Comment.class);

for(List<Comment> postcomments : allComments){
    for (Comment comment : postcomments){
        String commentTemp = comment.getId() +" "+ comment.getFrom().getId() +" "+ comment.getCreatedTime() +" "+ comment.getMessage() +" "+ comment.getLikeCount() +" "+ comment.getComments()+" "+myArr1.get(xy);
    }
}

All the function returns me the correct value except for the comment.getcomments()

kiheru
  • 6,588
  • 25
  • 31

2 Answers2

0

You should use the fetchConnection on the comment-id/comments. This is perhaps a bit expensive, but so you can fetch really all replies.

Norbert
  • 1,391
  • 1
  • 8
  • 18
0

Hi I am using restfb and found similar problem; the issue is that the connection.getData() returns only the first page of data. I used the iterator and was able to get all the comments. Please note you would have to do the same thing even for replies of comments; you will need to create a separate connection using comment id, instead of post id and then iterate out the comments in the same way shown below.

Connection<Comment> commentsConnection=   fbClient.fetchConnection(post.getId()+"/comments",com.restfb.types.Comment.class);

                 if(commentsConnection!=null)
                 {                   
                     Iterator<List<Comment>> commentsIterator=commentsConnection.iterator();
                     while(commentsIterator.hasNext())
                     {
                         List<Comment> comments= commentsIterator.next();

                         for(Comment comment:comments)
                         {
                             String message=comment.getMessage();
                         }
                     }
                 }
hss
  • 1
  • 1