开发者

Query for a Facebook user's favorite games

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?


This is what the documentation says about /user/games:

Games the user has added to the Arts and Entertainment section of their profile.

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 the user_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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜