How do I retrieve country using Facebook Unity Plu

2019-08-07 23:14发布

Environment:

  • Facebook Unity Plugins v6.2.2
  • Unity 4.6.8 p1
  • GraphAPI 2.4

Problem

Using Unity with the above SDK Plugin installed, I enter the following:

(public_profile,user_friend,user_location,_user_hometown)

However the return does not include the hometown. How can I make it so it returns the correct value?

I have tried the codes on the following page, but was unsuccessful: How to retrieve user country using facebook Graph API?

Thanks

FYI, The above command works fine if I use the GraphAPI explorer

2条回答
The star\"
2楼-- · 2019-08-07 23:46

After

FB.Init(OnInitComplete, OnHideUnity);

and

FB.Login("'permissions'", LoginCallback);

things (by the way you don't need any extra permissions to get country) this code will give you country

void Get()
{
    FB.API("me", Facebook.HttpMethod.GET, UserCallBack);
}

void UserCallBack(FBResult result)
{
    if (result.Error != null)
    {
        Debug.Log("FB.API result = null");
    }
    else
    {
        var dict = Facebook.MiniJSON.Json.Deserialize(result.Text) as IDictionary;
        country = dict["locale"].ToString();
    }
}
查看更多
萌系小妹纸
3楼-- · 2019-08-07 23:51

Has your app passed the login review process for the extended permissions user_location and user_hometown?

See

查看更多
登录 后发表回答