Reputation: 1715
I am new to using Facebook's API. I am trying to figure out how to access a user''s News Feed.
mFacebookLoginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newGraphPathRequest(loginResult.getAccessToken(), "/me/home", new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
}
});
I am confused to how to access the posts. Any help would be much appreciated.
Upvotes: 1
Views: 158
Reputation: 2364
The news feed info will be formatted in JSON format in the response so you are going to have to look into how to parse JSON string. But to get the JSON from the "graphResponse" you can do the following in the onCompleted method:
@Override
public void onCompleted(GraphResponse graphResponse) {
JSONObject jsonObject = graphResponse.getJSONObject();
try {
//parse through jsonObject here
}
catch (JSONException e) {
//log exception
}
}
Check out this for more info on Parsing JSON Arrays: How to parse this nested JSON array in android
Upvotes: 1