How do I retrieve country using Facebook Unity Plugins v6.2.2

佐手、 提交于 2020-01-16 04:16:06

问题


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


回答1:


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

See

  • https://developers.facebook.com/docs/facebook-login/review/what-is-login-review
  • https://developers.facebook.com/docs/facebook-login/best-practices#loginreview



回答2:


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();
    }
}


来源:https://stackoverflow.com/questions/32450576/how-do-i-retrieve-country-using-facebook-unity-plugins-v6-2-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!