简体   繁体   中英

Facebook SDK Unity me/friends v2.2 returns 0

I have issue with getting friends id, name and picture, I have FB.API at Start and deserialize results at own method. I am using test users from Facebook Developers page.

Here is Start() code

FB.API("/me/friends", Facebook.HttpMethod.GET, DealWithFriendName);

Here is code to deserialize it so I can get id out of it. Havent yet coded to get name or picture

void DealWithFriendName(FBResult result)
{
    if (result.Error != null)
    {
        Debug.Log("Problem with getting user data");
        FB.API("/me/friends", Facebook.HttpMethod.GET, DealWithFriendName);
        return;
    }
    Friends = Util.DeserializeJSONFriends(result.Text);

    foreach (object id in Friends)
    {
        var entry = (Dictionary<string, object>)id;
    }
    Debug.Log(Friends.Count);
    for(int i=0;i < Friends.Count;i++)
    {
        Debug.Log(Friends[i]);
    }
}

Friend List count is 0 even if I have created 3 test users and they are friends with each other.

I am clueless what to try anymore.

This is the like 1000th question for this topic. You only can get those friends which also use your app:

In Graph API v2.0, access to /me/friends is no longer part of the default (public_profile) permissions. We now require you to ask for the new permission user_friends. With this permission, /me/friends now returns the person's friends who are also using the app.

Creating test accounts does not automatically associate them with your app. The default option is to have them not installed, which means when you query the friends API you will get the behavior @Tobi mentioned on Facebook API v2.x.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM