krrishna
krrishna

Reputation: 2078

how to access user feed/posts using android facebook sdk

I want to read a facebook logged in user feed/stories published by him/her or from friends pages or groups etc visible on their wall.

I was able to accomplish login, reading user posts. But i was not able to figure out how i read the posts/ feed from other users which we normally see from friends or pages or groups when they open facebook proprietary app.

The only workaround i can think of is reading friends list and their posts and showing them on current logged in user posts. Not sure why i get the same result when i use me/feed or me/posts.

    Bundle params = new Bundle();
    params.putString("fields", "message,created_time,id,full_picture,status_type,source,comments.summary(true),likes.summary(true)");
    params.putString("limit", "100");
    /* make the API call */
    new GraphRequest(AccessToken.getCurrentAccessToken(), "/me/feed", params, HttpMethod.GET,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                    /* handle the result */
                    System.out.println("Festival Page response::" + String.valueOf(response.getJSONObject()));

                    try {
                        JSONObject jObjResponse = new JSONObject(String.valueOf(response.getJSONObject()));
                        System.out.println(jObjResponse);
                    }
                    catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
    ).executeAsync();

}

Upvotes: 0

Views: 1457

Answers (1)

Hamza Rashid
Hamza Rashid

Reputation: 1387

This is documented on the User object of the Graph api. And, as of the Graph API v2.6, there is basically one main endpoint from which you get posts from a user.

  • /{user-id}/feed includes all the things that a user might see on their own profile feed; this includes, e.g., shared links, checkins, photos and status updates. This also includes posts made by friends on the user's profile.

The following endpoints return subsets of the above:

  • /{user-id}/posts returns the posts created by the user (on their own profile or the profile of a friend), and it may include any kind of content such as shared links, checkins, photos and status updates.
  • /{user-id}/tagged returns the posts created by friends and shared on the users's profile.

By default each returned post only includes the story field with a textual description of the post. But you can use the ?fields=... parameter to request as many Post fields as you want.

You'll need the user_posts permission for any of these to work.

The following endpoints are deprecated:

  • /{user-id}/statuses returns only status updates posted by the user on their own profile. [removed after Graph API v2.3]
  • /{user-id}/home returns a stream of all the posts created by the user and their friends, i.e. what you usually find on the “News Feed” of Facebook. [removed after Graph API v2.3]

Upvotes: 1

Related Questions