简体   繁体   中英

Facebook sdk graph response is null

I'm trying to get list of friends using my application, I wrote the following code from facebook sdk :

   FacebookSdk.sdkInitialize(getApplicationContext());
      new GraphRequest(
     AccessToken.getCurrentAccessToken(),
     "me/friends?fields=name,email",
     null,
     HttpMethod.GET,
     new GraphRequest.Callback() {
         public void onCompleted(GraphResponse response) {
             /* handle the result */
             Log.d("-@-", "graph response " + response.getJSONObject());
         }
     }
 ).executeAsync();  

Here is my logcat :

09-17 16:55:29.226: D/com.facebook.GraphRequestAsyncTask(8087): execute async task: {RequestAsyncTask:  connection: null, requests: [{Request:  accessToken: {AccessToken token:ACCESS_TOKEN_REMOVED permissions:[contact_email, email, public_profile]}, graphPath: me/friends?fields=name,email, graphObject: null, httpMethod: GET, parameters: Bundle[{}]}]}
09-17 16:55:29.226: W/FacebookSDK.Request(8087): starting with Graph API v2.4, GET requests for /me/friends?fields=name,email should contain an explicit "fields" parameter.
09-17 16:55:29.226: W/System.err(8087): java.lang.Exception
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.internal.Logger.log(Logger.java:92)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.internal.Logger.log(Logger.java:77)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.GraphRequest.validateFieldsParamForGetRequests(GraphRequest.java:1648)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.GraphRequest.toHttpConnection(GraphRequest.java:1039)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1147)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.GraphRequestBatch.executeAndWaitImpl(GraphRequestBatch.java:252)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.GraphRequestBatch.executeAndWait(GraphRequestBatch.java:201)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.GraphRequestAsyncTask.doInBackground(GraphRequestAsyncTask.java:169)
09-17 16:55:29.236: W/System.err(8087):     at com.facebook.GraphRequestAsyncTask.doInBackground(GraphRequestAsyncTask.java:1)
09-17 16:55:29.236: W/System.err(8087):     at android.os.AsyncTask$2.call(AsyncTask.java:288)
09-17 16:55:29.236: W/System.err(8087):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-17 16:55:29.236: W/System.err(8087):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-17 16:55:29.236: W/System.err(8087):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-17 16:55:29.236: W/System.err(8087):     at java.lang.Thread.run(Thread.java:841)
09-17 16:55:29.396: D/-@-(8087): graph response null

The graph response is null, any help please ?

我解决了它们,问题是我在登录时没有获得“user_friends”的许可。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM