2

I'm trying to retrieve a list of all friends, but it always returns a zero size list... No exception nor fail...

I'm using following permissions:

Permission[] permissions = new Permission[] {
            Permission.BASIC_INFO,
            Permission.READ_FRIENDLISTS
    };

and I'm using following code:

private static OnFriendsListener mOnFriendsListener = new OnFriendsListener()
{
    @Override
    public void onComplete(List<Profile> friends)
    {
        L.d(FacebookHelper.class, "OnFriendsListener::onComplete");
        BusProvider.getInstance().post(new FacebookEvent(Type.Friends, friends));
    }

    @Override
    public void onException(Throwable throwable)
    {
        L.d(FacebookHelper.class, "OnFriendsListener::onException");
        L.e(FacebookHelper.class, new Exception(throwable));
    }

    @Override
    public void onThinking()
    {
    }

    @Override
    public void onFail(String reason)
    {
        L.d(FacebookHelper.class, "OnFriendsListener::onFail");
    }
};

public static void getFriends(SimpleFacebook simpleFacebook)
{
    PictureAttributes pictureAttributes = Attributes.createPictureAttributes();
    pictureAttributes.setType(PictureType.SMALL);

    Properties properties = new Properties.Builder()
            .add(Properties.ID)
            .add(Properties.FIRST_NAME)
            .add(Properties.LAST_NAME)
            .add(Properties.PICTURE, pictureAttributes)
            .add(Properties.BIRTHDAY).build();

    simpleFacebook.getFriends(properties, mOnFriendsListener);
}

Can anybody help me out with this problem?

1
  • I hate to say it, but I think this is effectively the same problem as stackoverflow.com/questions/23417356 In particular, this might mean the problem might not be soluble; from the answer to that question: "In v2.0 of the Graph API, calling /me/friends returns the person's friends who also use the app … In other cases, apps are no longer able to retrieve the full list of a user's friends (only those friends who have specifically authorized your app using the user_friends permission). This has been confirmed by Facebook as 'by design'." Commented Jun 4, 2014 at 15:29

1 Answer 1

2

Are you using the Facebook SDK for Android v3.14? If so, make sure to request the "user_friends" permission which lets the app read friends who also logged into the app with Facebook.

Note: v3.14 uses Graph API 2.0 by default. In that version of the API, GET /me/friends returns friends who logged into the app with Facebook.

If you're building a feature to tag friends in a post, take a look at the Taggable Friends API:

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

More info on the 2.0 changes is here:

https://developers.facebook.com/docs/apps/changelog#v2_0_login

Sign up to request clarification or add additional context in comments.

2 Comments

at the moment, the library works only with 3.8 and that's what I'm using... Btw, I don't want to read a list of friends that are logged in with the app, but just a list of all friends... I want to make a image sync tool for my android contacts...
If you created your app after 04/30/2014, then you're using Graph API 2.0, and you should use v3.14 since v3.8 is not compatible with Graph API 2.0. In Graph API 2.0, you can no longer get a list of all friends, only friends who also use the app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.