Get the number of posts you like on the FB page using the RestFB API

I try to get all the messages, the number of messages I liked in each message, the comments for each message and the number of comments I liked for each comment from a specific FB page ( https://www.facebook.com/JnuConfessions ). I am using RestFB for this.

While I managed to get the content of the message, the comments and comments of the comments I liked correctly, I can not get the number of posts you like. I am using the following code

Page page = facebookClient.fetchObject("jnuConfessions", Page.class);
Connection<Post> myPagePost = facebookClient.fetchConnection(page.getId() + "/posts", Post.class);
for (List<Post> myFeedConnectionPage : myPagePost) {
   for (Post post : myFeedConnectionPage) {
      System.out.println ("Number of likes: " + post.getLikesCount());
   }
}

However, for each message I just get a null value instead of the correct number of likes.

Is there a way to get the number of likes of each post correctly?

+4
1

, , .

            for (List<Post> myFeedConnectionPage : myFeed) {
                for (Post post : myFeedConnectionPage) {
                    //JSONObject userPosts = new JSONObject();

                    try {
                        post = facebookClient
                                .fetchObject(
                                        post.getId(),
                                        Post.class,
                                        Parameter
                                                .with("fields",
                                                        "from,actions,message,story,to,likes.limit(0).summary(true),comments.limit(0).summary(true),shares.limit(0).summary(true)"));
                    System.out.println ("Number of likes: " + post.getLikesCount());
                    } catch (Exception e) {
                        e.printStackTrace();

                    }
                }
            }
0

Source: https://habr.com/ru/post/1525802/


All Articles