How to extract on the public page owner's posts on restfb?

550 views Asked by At

I have a working restfb Java program that can extract posts. But it will extract posts from everyone who posted in the wall, including the owner of the page. It is OK with less popular pages, but for popular pages, they are mostly fan posts. For example, if I extract posts from https://www.facebook.com/GameOfThrones, 199 out of 200 posts are fan posts.

I currently have a if loop to check the name of the person but sometimes the page ID is different from the post owner's ID.

Is there any generic and efficient way of doing this? I was hoping there is a parameter or something that filters out fan posts on a public page.

Here is what I have now:

    FacebookClient fbclient = new DefaultFacebookClient(ACCESS_TOKEN, Version.VERSION_2_3); 

    Connection<Post> message = fbclient.fetchConnection(name + "/feed", com.restfb.types.Post.class, Parameter.with("limit", 200)); 
    List<Post> detailedPost = message.getData(); 
    ....
    for (int i = 0; i < detailedPost.size(); i++) {
        String id = message.getData().get(i).getId();
        personPosted[i] = detailedPost.get(i).getFrom().getName().toString(); 
        if (personPosted[i].equals(name)) {
        ...
        }
   }
1

There are 1 answers

1
CBroe On

https://developers.facebook.com/docs/graph-api/reference/v2.3/page/feed:

/{page-id}/feed

The feed of posts (including status updates) and links published by this page, or by others on this page. There are other edges which provide more specific sets of posts:

  • /{page-id}/posts shows only the posts that were published by this page.
  • […]