查询Facebook用户最喜欢的游戏
我正在尝试获取 Facebook 用户的游戏列表。为此,我使用 Graph API 调用
https://graph.facebook.com/MY-USER-ID/games
对于我的特定测试,响应如下所示帐户:
{ "data": [ { "name": "CityVille",
"category": "Games/toys",
"id": "CITYVILLEID",
"created_time": "2011-08-24T01:14:32+0000" } ]
因此,我正在获取与用户关联的应用程序之一(在用户的收藏夹栏中)。但响应中缺少用户收藏的其他四个应用程序。有什么原因导致此响应不完整吗?我已经检查了应用程序隐私设置,对于所有其他已安装的应用程序,它们与 Cityville 相同。
第二个相关问题是,我试图将上面的游戏调用中返回的游戏与 FQL 应用程序表中的项目进行匹配。我获取了上面响应返回的 ID,并将其用作我的 FQL 索引的匹配索引。
SELECT app_id, display_name, category, subcategory
FROM application WHERE app_id = CITYVILLEID
但在 Cityville 的特定情况下,上面的 Graph API 调用中返回的 ID 是应用程序 Facebook 页面(个人资料页面)的 ID,而不是 FQL 表中的 ID。所以我的查询结果是空的。最终我确实在应用程序 FQL 表中找到了该条目,但它是通过 canvas_name 查找的。
我的第二个问题是,有没有什么方法可以通过 facebook API 将图形 API 中的游戏与 FQL 应用程序表中的应用程序条目关联起来?
I am trying to fetch a Facebook user's list of games. To do that I am using the Graph API call
https://graph.facebook.com/MY-USER-ID/games
The response looks like this for my particular test account:
{ "data": [ { "name": "CityVille",
"category": "Games/toys",
"id": "CITYVILLEID",
"created_time": "2011-08-24T01:14:32+0000" } ]
So, I am getting one of the applications associated to the user (in the user's favorites bar). But the response is missing four other applications that the user has in her favorites. Is there any reason why this response would be incomplete? I have checked the application privacy settings and they are the same as Cityville for all other installed applications.
A second related question, is that I am trying to match the games returned in the games call above to items in the FQL applications table. I was taking the id returned by the response above and matching it using it as the match index to my FQL index.
SELECT app_id, display_name, category, subcategory
FROM application WHERE app_id = CITYVILLEID
But in the particular case of Cityville, the ID returned in the Graph API call above, is the ID for the application's Facebook page (profile page), NOT the id in the FQL table. So the result of my query was empty. Eventually I did find the entry in the application FQL table, but it was by looking for it by canvas_name.
My second question is, is there any way to associate the games from the graph API to application entries in the FQL application table, through the facebook API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是文档关于
/user/games:
这与用户玩的游戏(Facebook 应用程序)没有任何关系。我认为没有任何方法可以直接获取该列表。
同一文档报告了使用
user_games_activity
扩展权限读取用户游戏分数 (/user/scores
) 的可能性。我对分数 API 不熟悉,所以我在这里可能是错的:这可能会引导您找到用户玩的游戏,但显然只有那些使用此方法保存分数的游戏。This is what the documentation says about
/user/games
:That doesn't have anything to do with the games (Facebook apps) the user plays. I don't think there is any way to get that list directly.
The same documentation reports the possibility to read a user's game scores (
/user/scores
) with theuser_games_activity
extended permission. I am not familiar with the scores API, so I may be wrong here: this may lead you to the games the user plays, but obviously only those that save scores with this method.图形 API 中的游戏边缘指的是与应用程序关联的页面...因此您从中获得的 ID 是页面的 ID,它不会与应用程序的 ID 匹配。一般来说,用户并不“喜欢”他们玩的游戏的所有页面,因此我不建议使用这种方法。也没有可靠的方法从页面 ID 获取关联的应用程序 ID。
MartinodF 是对的,目前还没有办法列出用户的应用程序,但这是我们未来正在考虑的事情。如果有一种方法,那么只有当用户授予您 user_games_activity 扩展权限时,它才会被允许,正如他所建议的那样。
The games edge in the graph API is referring to the page associated with the application... so the ID you get from that is the page's, and it will not match an application's ID. Users in general have not 'liked' all the pages of the games they play, so I wouldn't recommend using this approach. There is also no reliable way to get from the page ID to an associated app ID.
MartinodF is right, there's currently no way to list a user's apps, but it is something we are considering for the future. If there were a way, it would indeed be allowed only if the user grants you the
user_games_activity
extended permission, as he suggests.