Unity Facebook SDK

Hi,

I am trying to use the Facebook SDK for Unity to get people from my friends list and display their names/profile pictures. I have followed through the FriendSmash tutorials and stuff on the Unity page, and downloaded the FriendSmash project (which wouldn’t even log me in properly sadly) but it is still not working.

I am trying to use the following code from the tutorial:

void OnLoggedIn()
{
    Util.Log("Logged in. ID: " + FB.UserId);

    // Reqest player info and profile picture
    FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
    LoadPicture(Util.GetPictureURL("me", 128, 128),MyPictureCallback);

}
    
void APICallback(FBResult result)
{
    Util.Log("APICallback");
    if (result.Error != null)
    {
        Util.LogError(result.Error);
        // Let's just try again
        FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
        return;
    }
        
    profile = Util.DeserializeJSONProfile(result.Text);
    GameStateManager.Username = profile["first_name"];
    friends = Util.DeserializeJSONFriends(result.Text);
}

I have debug messages at every line after the result.Error braces, and the code doesn’t seem to hit the line after:

profile = Util.DeserializeJSONProfile(result.Text);

although it DOES get through that function. (Debug logs at the beginning and just before it returns both are output in logcat).

The profile/friends variables are remaining null after I am setting them.

Has anybody used this API and had these problems before?

Unity version is 4.5.2 and Facebook SDK is 5.1

EDIT: Forgot to add, after the above code, I can get my profile picture, but not my name or friends or anything like that (anything useful)

Thanks,
Sosp

Since some time, facebook will return only friends who logged into app, sorry. You can create several test users (on creation add app permissions already) in the dashboards (roles/test users), add other test users as friends, and than when you launch your app in unity instead of your token use token of one of the test users (from dashboard) , you will be able to retrieve data of their friends (other test users).