I have been trying to get the user’s country using the Facebook API, but I keep getting an error.
permissions.Add("user_location");
FB.API("/me?fields=location", HttpMethod.GET, DisplayLocation);
void DisplayLocation(IResult result)
{
FacebookLocation = result.ResultDictionary["user_location"];
PlayerPrefs.SetString("location", FacebookLocation.ToString());
}
However it keeps giving an 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.DisplayLocation (IResult result) (at Assets/Scripts/facebook.cs:220)
Facebook.Unity.AsyncRequestString+c__Iterator1.MoveNext () (at Assets/Facebook/Scripts/Utils/AsyncRequestString.cs:132)
Please can someone kindly give some advice? Thanks!