我正在尝试使用我的应用程序获取朋友列表,我从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();
这是我的日志:
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
图形响应为空,有什么帮助吗?
最佳答案
我解决了,伙计们,问题是我登录时没有“用户朋友”的权限。