parsedjson 字符串 - 名称返回不带特殊字符
我想获取点击登录的用户名。我已经成功地做到了这一点。唯一的问题是带有特殊字符的名称。例如,我的名字: - 哈瓦尔·比约恩塞斯 带有特殊字符; å 和 ø,将返回:Hávar Bjårnseth
有什么方法可以解决此问题,以便返回正确的字母?
我用来检索名称的代码:
$pageContent = file_get_contents('http://graph.facebook.com/' . $user_id);
$parsedJson = json_decode($pageContent);
echo $parsedJson->name;
如果你们中有人知道如何使用 Javascript SDK 调用该名称,我很想听听!谢谢 :)
I want to fetch the name of users clicking on login. I've done this successfully.. The only problem is names with special characters. FOr instance, my name:
- Håvar Bjørnseth
with the special characters; å and ø, will return: HÃ¥var Bjørnseth
Is there any way to fix this so that the correct letters will return?
The code I used to retrieve the name:
$pageContent = file_get_contents('http://graph.facebook.com/' . $user_id);
$parsedJson = json_decode($pageContent);
echo $parsedJson->name;
If any of you know how to call the name using Javascript SDK, I would love to hear about it! Thank you :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以尝试访问链接
https://developers.facebook.com /tools/explorer?method=GET&path=704597208
您可以观察到 facebook 返回了正确的字符。我认为您的问题在于您正在使用的字符编码。也许您可以尝试将获得的名称转换为您想要的编码。
If you can try to access the link
https://developers.facebook.com/tools/explorer?method=GET&path=704597208
You can observe that facebook is returning the correct characters. I am thinking your problem is with the character encoding which you are using. Probably you can try converting the name you get to your desired encoding.
您还可以尝试使用 Facebook PHP SDK。它应该自动处理编码问题。请参阅:http://developers.facebook.com/docs/reference/php/
You can also try to use the Facebook PHP SDK. It should automatically handle the encoding issues. See: http://developers.facebook.com/docs/reference/php/