Facebook C# SDK get user language/region

不问归期 提交于 2019-12-22 09:47:00

问题


I'm using the Facebook C# SDK. How can I get language of the user, so I can display all messages accordingly without forcing the user to choose his preferred language manually?


回答1:


If you are developing a web app, then you can use Accept-Language Http header to detect the language


EDIT 1

For winforms application, you can use System.Globalization.CultureInfo.CurrentCulture.Name .


EDIT2

To get the locale using FB REST API :

dynamic fbResult = new Uri("https://graph.facebook.com/AngelaMerkel?access_token=AAABkECTD......").GetDynamicJsonObject();
Console.WriteLine(
    fbResult.locale ?? "-" + " > " +  //<----
    fbResult.location.country + " " + //<----
    fbResult.location.city + " " + //<----
    fbResult.name + " " + 
    fbResult.gender + " " + 
    fbResult.link + " " + 
    fbResult.updated_time);

You can find info about my extension method GetDynamicJsonObject here



来源:https://stackoverflow.com/questions/8185347/facebook-c-sharp-sdk-get-user-language-region

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