Facebook Graph API - 用户名语言的不一致性

时间:2014-08-26 05:09:22

标签: php facebook facebook-graph-api

我正在测试使用Facebook PHP SDK的网络应用程序。我从其他帖子中读到,用户可以在唯一的名称字段中选择要显示的名称。这是真的吗?

我的名字可以是两种语言:英文和中文。但当我测试我的应用时,它有时使用我的中文版,但是当我重新加载时,它总是显示英文版。

PHP:

$user = $facebook->getUser();
$user_profile = $facebook->api('/'.$user);
//the line was: $user_profile = $facebook->api('/me');
//name was always English back then
//but it cause the expired token problem
$username = $user_profile['first_name'] . " " .  $user_profile['last_name'];
echo $username;

有时输出:

志榮 張 //By the way, the Chinese name suppose to be 張志榮

经常输出:

Daniel Cheung

为什么会这样?由于显示的名称将被记录,因此数据看起来非常不一致,并且很难用我的数据库对其进行处理。

我可以告诉Facebook只发送英文名称吗?因为当人们使用英文版的Facebook时,他们会看到我的英文名字。中国Facebook总是显示我的中文名字。

1 个答案:

答案 0 :(得分:0)

您可以将locale参数传递给Graph API请求。看看

https://developers.facebook.com/docs/graph-api/using-graph-api/v2.1#readmodifiers

有了这个,你至少应该能够检索到一致的结果。