在进行一些搜索之后用于获取列表的代码如下所示
GraphRequestBatch batch = new GraphRequestBatch( GraphRequest.newMyFriendsRequest( accessToken,new GraphRequest.GraphJSONArrayCallback() { @Override public void onCompleted( JSONArray jsonArray,GraphResponse response) { // Application code for users friends System.out.println("getFriendsData onCompleted : jsonArray " + jsonArray); System.out.println("getFriendsData onCompleted : response " + response); try { JSONObject jsonObject = response.getJSONObject(); System.out.println("getFriendsData onCompleted : jsonObject " + jsonObject); JSONObject summary = jsonObject.getJSONObject("summary"); System.out.println("getFriendsData onCompleted : summary total_count - " + summary.getString("total_count")); } catch (Exception e) { e.printStackTrace(); } } }) ); batch.addCallback(new GraphRequestBatch.Callback() { @Override public void onBatchCompleted(GraphRequestBatch graphRequests) { // Application code for when the batch finishes } }); batch.executeAsync(); Bundle parameters = new Bundle(); parameters.putString("fields","id,name,link,picture");
我得到的许可是
accessToken:{AccessToken令牌:ACCESS_TOKEN_REMOVED权限:[user_friends,basic_info]}
getRecentlyGrantedPermissions:[user_friends,basic_info]
getRecentlyDeniedPermissions:[]
响应{响应:responseCode:200,graphObject:{“summary”:{“total_count”:3},“data”:[]},错误:null}
提前完成.
解决方法
输出正确,您的朋友都没有授权您的应用程序.从图谱API的2.0版开始,出于隐私原因,您只能获得授权您的应用的朋友:
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/friends
更多信息可以在这个主题中找到:Get ALL User Friends Using Facebook Graph API – Android