通过 Graph API 获取用户特定区域的兴趣和活动
我们正在开发一款可以访问 Facebook 用户数据的移动应用程序。
我们想要获取用户的活动、兴趣以及最喜欢的书籍、音乐等。我们通过 Graph API 获取这些信息,但现在我们面临的问题是,返回的兴趣是英语。
这是我们获取共同兴趣所采取的步骤:
1) 获取访问令牌
2) 调用 https://graph.facebook.com/me/interests&access_token=XXX0&locale=de_DE
响应有点像:
{"data":[{"name":"Programming","category":"Interesse","id":"101882226520576","created_time":"2011-08-02T08:38:03+0000"}]}
你可以看到,该类别已翻译,但我们也在寻找名称字段的德语版本(“Programmierung”)。
当我尝试访问 http://www.facebook.com/ 上的英文“编程”页面时pages/Programming/101882226520576 我被转发到 http://www.facebook.com/pages/Programmieren/106375099398136。
使用图形 API 访问 106375099398136 会产生正确的响应:
{
"id": "106375099398136",
"name": "Programmieren",
"link": "http://www.facebook.com/pages/Programmieren/106375099398136",
"likes": 6983,
...
}
How do i get this locale dependent link between "Programming"-page and "Programmierung"-page via the Graph API?
we are working on a mobile app that accesses facebook user data.
We want to get the users activities, interests and favorite books, music, etc. We are fetching these information via the Graph API but now we are facing the problem, that the returned interests are in english language.
That are the steps we are taking to fetch common interests:
1) Get access token
2) Call https: //graph.facebook.com/me/interests&access_token=XXX0&locale=de_DE
The response is somewhat like:
{"data":[{"name":"Programming","category":"Interesse","id":"101882226520576","created_time":"2011-08-02T08:38:03+0000"}]}
You can see, that the category is tanslated, but we are also looking for the german version of the name field ("Programmierung").
When i try to access the english "Programming"-page on http://www.facebook.com/pages/Programming/101882226520576 i am forwarded to http://www.facebook.com/pages/Programmieren/106375099398136.
Accessing 106375099398136 with Graph API yields the correct response:
{
"id": "106375099398136",
"name": "Programmieren",
"link": "http://www.facebook.com/pages/Programmieren/106375099398136",
"likes": 6983,
...
}
How do i get this locale dependent link between "Programming"-page and "Programmierung"-page via the Graph API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是想分享上述问题的可能解决方法。
基本上,我们正在模拟当用户尝试访问 Facebook 页面并被重定向到本地化对应页面时所发生的情况。因此,我们将 HTTP 请求发送到“facebook.com/pages/PAGE_ID”,并在 HTTP 标头中设置用户区域设置,并遵循重定向直到最后一个位置。最后一个位置的 URL 有点像“http://www.facebook.com/pages/LOCALIZED_PAGE_NAME/PAGE_ID”,我们正在从中提取页面名称。
这是一个有效但远非有效的解决方案:)希望有一种更优雅的方式来处理这个问题。
再见,
托比亚斯
just want to share a possible workaround for the above problem.
Basically we are emulating what is happening when the user trys to access a facebook page and is redirected to the localized counterpart. So we are sending a HTTP request to "facebook.com/pages/PAGE_ID" with the user locale set in the HTTP header and follow the redirects until the last location. The URL of the last location is somewhat like "http://www.facebook.com/pages/LOCALIZED_PAGE_NAME/PAGE_ID" and we are extracting the page name from this.
This is an effective but far from efficient solution :) Would appreciate a more elegant way to handle this.
Bye,
Tobias