Facebook Graph API: get comments by given user
Asked Answered
H

1

8

In Facebook Graph API, can we get list of comments made by given user.

I haven't found any direct way to get lists of comments. So, I tried to find them through my feed, but it's returning all feed posts. Can we filter other posts where I have not commented?

I tried various queries as below, but could not get exactly what I need.

/me/feed?fields=comments?fields=from?name="Nitin Thokare",message

/me/feed?fields=comments.fields(from.name("Nitin Thokare"),message)

I need either (1) list of all comments by me or else (2) lists of posts which I have commented on, filtering out all other posts. How can we do this? (Finally I'll be using Java api to do the same.)

Hartill answered 15/3, 2013 at 6:43 Comment(1)
i dont think there's a way to do this. The closest method would be to get the activity log and filter out the comments. You might wanna see this too #6664279Bellow
K
0

you can get the list of comments of an user by using spring supported Facebook API. To access any information of an user you have to pass access token of that particular user. To get list of comments, you have to create FaceBookTemplate object by passing access token and by using that get FeedOperations object. By using FeedOperations object you can get feed,posts,status,links and so on. Get the list of post and iterate each and every post and get all the comments of the post which was made by you on that post.

eg code:-

    FaceBook faceBook = new  FaceBookTemplate(accessToken);
    FeedOperations feeds=faceBook.feedOperations();
    List<Post> posts=feeds.getPosts();
    List<Comment> comments=new ArrayList<>();

    for(Post post:posts){
        List<Comment> commentsList = post.getComments();

        for(Comment comment:commentsList){
                comments.add(comment);
        }
    }
Keitel answered 12/8, 2014 at 5:8 Comment(1)
Won't that only get comments the user left on their own posts ?Masters

© 2022 - 2024 — McMap. All rights reserved.