Android Facebook friendsList array is null but Fri

2019-07-24 07:54发布

问题:

My permissions:

facebookLoginButton.setReadPermissions(
    Arrays.asList("public_profile", "user_friends","read_friendlists"));

Callback functions:

new Request(Session.getActiveSession(), "/" + USER_ID + "/friends", null, HttpMethod.GET,
    new Request.Callback() {
        public void onCompleted(Response response) {
            showLogInfo("###########" + response.getRawResponse());
        }
    }).executeAsync();

This above function I'm calling to get facebook friends list. but I'm getting following response.

{"summary":{"total_count":342},"data":[]}

My doubt is I'm getting total count. but why can't I get data list ? Please someone help me to Identify my mistake. Thanks in Advance.

回答1:

It is not possible to get ALL friends with v2.0+, only with Apps created before end of April 2014 by using v1.0 of the Graph API. And it will only work until end of April 2015. See changelog for more information about the versions: https://developers.facebook.com/docs/apps/changelog

There is also invitable_friends and taggable_friends though, but they are reserved for Apps on facebook.com:

  • https://developers.facebook.com/docs/graph-api/reference/v2.1/user/invitable_friends
  • https://developers.facebook.com/docs/graph-api/reference/v2.1/user/taggable_friends

This may also be interesting for inviting friends: https://developers.facebook.com/docs/games/requests/v2.1

Here´s another thread where this is explained in a very detailed way: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app



回答2:

New facebook graph api does not allow friend list access, you can only get count and Tagged friends

Check this link developers.facebook.com/docs/graph-api/reference/v2.1/user/ where it is clearly mentioned that

  • This will only return any friends who have used (via Facebook Login) the app making the request.

  • If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person