Facebook C#SDK获取用户语言/区域 [英] Facebook C# SDK get user language/region

查看:114
本文介绍了Facebook C#SDK获取用户语言/区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook C#SDK。如何获取用户的语言,所以我可以相应地显示所有消息,而不会强迫用户手动选择他的首选语言。

解决方案

p>如果您正在开发网络应用程序,则可以使用 Accept-Language Http标头来检测语言






编辑1



对于winforms应用程序,您可以使用系统.Globalization.CultureInfo.CurrentCulture.Name






EDIT2



使用FB REST API获取 locale

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

您可以找到有关我的扩展方法的信息 GetDynamicJsonObject 此处


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?

解决方案

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

这篇关于Facebook C#SDK获取用户语言/区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆