After following the facebook tutorial (https://developers.facebook.com/docs/games/unity/unity-tutorial) I’ve tried to adapt that information to my game.
I’ve already managed to make the login, the share function and retrieve some information like the user picture. But I’m not being able to make this work:
private static Dictionary<string, string> profile = null;
void OnLoggedIn()
{
Debug.Log("Logged in. ID: " + FB.UserId);
FB.API("/me?fields=name,email", Facebook.HttpMethod.GET, APICallback);
PlayerPrefs.SetString("username",profile["first_name"]);
PlayerPrefs.SetString("id",profile["id"]);
}
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", Facebook.HttpMethod.GET, APICallback);
return;
}
profile = Util.DeserializeJSONProfile(result.Text);
}
I made that to try to retrieve the user name and player id. But doesn’t work :
Can someone tell me why?