Hi, I have used the Facebook API to get the user’s first name and gender fine, but when I try to also get their birthday. I get an error. Here is the code (It works fine for name and gender but not birthday):
void AuthCallBack (IResult result)
{
if (result.Error != null)
{
Debug.Log(result.Error);
}
else
{
if (FB.IsLoggedIn)
{
//Get Username, first parametre is what you want to get, method, callback
FB.API("/me?fields=first_name", HttpMethod.GET, DisplayUsername);
FB.API("/me?fields=gender", HttpMethod.GET, DisplayGender);
FB.API("/me?fields=birthday", HttpMethod.GET, DisplayBirthday);
SceneManager.LoadScene("loggedinpage");
}
else
{
Debug.Log("not logged in");
}
}
}
void DisplayUsername (IResult result)
{
FacebookFirstName = result.ResultDictionary ["first_name"];
Debug.Log(FacebookFirstName.ToString());
}
void DisplayGender(IResult result)
{
FacebookGender = result.ResultDictionary["gender"];
Debug.Log(FacebookGender.ToString());
}
void DisplayBirthday(IResult result)
{
FacebookBirthday = result.ResultDictionary["birthday"];
Debug.Log(FacebookBirthday.ToString());
}
}
And here is the error:
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.String,System.Object].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
facebook.DisplayBirthday (IResult result) (at Assets/Scripts/facebook.cs:104)
Facebook.Unity.AsyncRequestString+c__Iterator1.MoveNext () (at Assets/FacebookSDK/SDK/Scripts/Utils/AsyncRequestString.cs:133)
Thanks a lot