Wednesday, 31 October 2012

Facebook - Finding a user's friends who use your app

This is something I've had to find before, but I'd forgotten the Facebook Graph API call to fetch it ... so here it is, written down so I can find it again later :)

This call returns all the user's friends (including their names) and adds a property of "installed" (set to true) to the object for each user that's also a user of the app:

https://graph.facebook.com/{userid}/friends?fields=installed,name

Of course, there are new ways of doing things since I last tried to do this and now, using FQL, you can fetch a list without the users who don't use the app. There's a field called is_app_user you can query against:

https://graph.facebook.com/fql?q=SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={userid}) AND is_app_user=1 ORDER BY name

Easy!

No comments:

Post a Comment