Aman
Aman

Reputation: 220

How to get Facebook Feeds (post) using facebook sdk 4.0 in android?

I have show facebook feeds(post) list in may application. I am using facebook 4.0 I am able to get profile but unable to fetch all my feeds(post). If anybody have any reference then please tell me. Thanks.

Right-now I am using following code for get Feeds but getting blank response like {"data":[]}

FacebookCallback<LoginResult> facebookCallback = new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {

            new GraphRequest(
                     AccessToken.getCurrentAccessToken(),
                     loginResult.getAccessToken().getUserId()+"/feed/",
                     null,
                     HttpMethod.GET,
                     new GraphRequest.Callback() {
                         public void onCompleted(GraphResponse response) {
                             Log.i("fb", "Feeds :" +response.getJSONObject());
                             Toast.makeText(
                                     getApplicationContext(),
                                     response.getJSONObject()
                                             + "",
                                     Toast.LENGTH_SHORT).show();
                         }
                     }
             ).executeAsync();

    }

Upvotes: 1

Views: 2589

Answers (3)

Ishaq
Ishaq

Reputation: 1

You should add the user_posts permission to your login request:

LoginManager.getInstance().logInWithReadPermissions(this,
Arrays.asList("public_profile ", "user_status","user_posts"));

Upvotes: 0

Dhruv Raval
Dhruv Raval

Reputation: 5034

Here,

You are not passing parameters like these:

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", "10");


/* make the API call */
        new GraphRequest(AccessToken.getCurrentAccessToken(), "/userId/posts", 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()));
                        }
                        catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
        ).executeAsync();

Hope to solving these issue i am solving into facebook SDK 4.6.0

Upvotes: 1

Helmi
Helmi

Reputation: 556

You need to make a graph api call from within your app https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed

Upvotes: 1

Related Questions