0

I have been using below code to get data from my facebook home using restFb api.

          import java.util.List;

          import com.restfb.Connection;
          import com.restfb.DefaultFacebookClient;
          import com.restfb.FacebookClient;
          import com.restfb.FacebookClient.AccessToken;
          import com.restfb.types.Post;
          import com.restfb.types.User;

          public class restFB_tester {

            public static void main(String[] args) {

                //60 days auth
                String authToken="XXXXXXX";

                FacebookClient fbClient = new DefaultFacebookClient(authToken);     
                Connection<Post> result=fbClient.fetchConnection("me/home",Post.class);

                int counter =0;
                for(List<Post> page :result)
                {
                  for(Post aPost:page)
                  {
                      System.out.println(aPost.getMessage());
                      System.out.println("fb.com/"+aPost.getId());
                      counter++;      
                  }
                }       
                System.out.println("No of Posts : "+counter);
            }

          }

And this throws an error :

Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: (#200) Requires extended permission: read_stream (code 200, subcode null) at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1186) at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1112) at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1053) at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:964) at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:926) at com.restfb.DefaultFacebookClient.fetchConnection(DefaultFacebookClient.java:356) at org.hive.facebook.restFB_tester.main(restFB_tester.java:29)

I have been trying to solve this but couldn't find any luck. I was able to get data if i use "me/feeds" ,that returns user data.I tried finding it on google and tried different ways but didn't help.I have given all permission while creating token.

Please let me know where i am doing wrong or what can be potential solution for this.Thanks in advance.

Ankit Agrahari
  • 349
  • 9
  • 22

1 Answers1

-1

Please let me know where i am doing wrong

You are using old code, and apparently did not bother to check the documentation for what is still possible in current API versions.

https://developers.facebook.com/docs/apps/changelog#v2_4_deprecations:

he GET /v2.4/{user_id}/home, GET /v2.4/{user_id}/inbox, and GET /v2.4/{user_id}/notifications operations as well as read_stream, read_mailbox, and manage_notifications permissions are deprecated in v2.4.

You simply can not get that data any more. You will have to make to with /me/feed, and the posts that delivers. (Which ones those are, is mentioned in the docs.)

CBroe
  • 91,630
  • 14
  • 92
  • 150