Getting Friends List Empty Facebook SDK 3.8 in And

2019-06-10 07:51发布

问题:

I am trying to fetch friends' list in Facebook SDK 3.8 but it returning Empty User List. I have also set the permissions of user_friends. Please see the following code.

<code>
    LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
    loginButton.setReadPermissions(Arrays.asList("user_friends"));

    Request request = Request.newMyFriendsRequest(session, new Request.GraphUserListCallback() {

                    @Override
                    public void onCompleted(List<GraphUser> users, Response response) {
                        Log.i("activitytag", "UserListSize: " + users.size());

                    }
                });
                request.executeAsync();
</code>

I am getting the UserListSize to 0. What am I missing?

回答1:

If you created your app after April 30, 2014, then you're using version 2.0 of the graph API, in which case the newMyFriendsRequest will only return friends who are also using your app. You should also update your SDK to the latest (3.14.1).



回答2:

In facebook api v2.0 has no way to get all friends list. but if you want to get all friend list ONLY IN GAME then you can call Either

Invitable Friends List: you may use the https://developers.facebook.com/docs/graph-api/reference/v2.0/user/invitable_friends API. OR Taggable Friends List:

the https://developers.facebook.com/docs/graph-api/reference/v2.0/user/taggable_friends

for more detail please read facebook change log:

Facebook Change log