在android中使用图形api 2.2从facebook sdk 4.0.1获取朋友列表

下面是一些搜索后用于获取列表的代码

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:[]

并且图形函数的输出是 -

响应{response:responseCode:200,graphObject:{“summary”:{“total_count”:3},“data”:[]},error:null}

所以任何人都可以请指导我取得用户的好友列表。

提前Thanx。


输出是正确的,你的朋友都没有授权你的应用程序。 从Graph API的v2.0开始,您只能获得授权您的应用的朋友,因为隐私原因:https://developers.facebook.com/docs/graph-api/reference/v2.3/user/friends

更多信息可以在此主题中找到:使用Facebook Graph API获取所有用户朋友 - Android

链接地址: http://www.djcxy.com/p/84377.html

上一篇: fetch friends list from facebook sdk 4.0.1 in android with graph api 2.2

下一篇: How to set a breakpoint in function body in R