2

I am extremely new to Facebook API codings and am trying to make a game application where users will be able to see who (in their friend list) is already using the game application. It is pretty much like all the popular Facebook games such as plock, pet society, etc. where users can view their friend's score, profile and ranking in the application.

I've Googled around and searched here for results but most of the methods are using FBML and the REST API which are currently being deprecated. The best I can find are all posts similar to the one here which retrieves the full friend list (which is not quite what I'm going for).

I was wondering if there's any way to implement what I want to do with the Graph API -> user_games_activity?

edit: I forgot to mention that the game is supposed to be integrated in Facebook itself

Community
  • 1
  • 1
Dap
  • 21
  • 1
  • 3
  • possible duplicate of [How to get photo and name from several ids at once](http://facebook.stackoverflow.com/questions/7289541/how-to-get-photo-and-name-from-several-ids-at-once) – bkaid Sep 04 '11 at 16:53

2 Answers2

4

Anytime a user uses your game, make sure their user id is in your database, in your users database table for example.

Then, anytime you need to generate the list of the current user's friends who play the game, grab the list of the current user's friends -- see /me/friends -- and check if any of the returned ids are in your users table.

Wayne Kao
  • 8,125
  • 5
  • 30
  • 25
  • Thank you for your reply! So does that mean i have to have an external database and i will not be using Facebook's query in anyway? – Dap Sep 04 '11 at 11:22
  • Yes, you will need to either maintain an external database as @WayneKao suggests, or get the user ID's in a roundabout way as suggested in my answer below. Facebook does not support the query "Give me all the users who use my application." unfortunately... – Andrew Kozak Nov 24 '11 at 03:15
0

You don't have to maintain a separate database if you store a starting score or an achievement for each users. To find friends' Games information, simply get .../me/friends for the current User, and then loop through each friend ID returned and query .../FRIEND_ID/scores or .../FRIEND_ID/achievements using the User's access_token.

Andrew Kozak
  • 1,631
  • 2
  • 22
  • 35
  • You can also call .../APP_ID/scores to retrieve the list of friends in one API call. – zippycoder Nov 20 '13 at 23:28
  • Note however, that the scores API will only return friends who have set visibility for the app to something wider than "Only Me". Wayne's answer above is a more robust solution, but obviously requires more db infrastructure. – zippycoder Nov 20 '13 at 23:30
  • Good addition @zippycoder Not sure if that functionality was not available at the time -- this *is* two years old -- or if I just overlooked it. Either way, thanks.~ – Andrew Kozak Nov 22 '13 at 02:57