The Facebook API gives you the option of using FQL (Facebook Query Language) to retrieve data instead of using the built in API calls. I thought this was unnecessary until I needed a quick query to get me the list of a users friends with the current application added. After some research, I came across the following query:
$facebook->api_client->fql_query("SELECT uid FROM user WHERE has_added_app=1 and uid IN (SELECT uid2 FROM friend WHERE uid1 = $user)");
This returns a nice quick list I can use in the multi-friend selector for excluded IDs in the ‘share’ part of the application as well as a quick number for how many friends have already added the application. This can be very useful.
Nice one! Thanks!
Roy — May 15th, 2011 at 9:41 pmProbably better like this tho
Roy — May 15th, 2011 at 9:43 pmSELECT uid FROM user WHERE has_added_app=1 and uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Thanks a lot ! This worked great for my app, and finding this info was much faster than searching it on the facebook documentation
BTW, I’m also posting the graph API url (with two PHP vars for user id and token), to save some time to someone who could need it:
https://graph.facebook.com/fql?q=SELECT+uid+FROM+user+WHERE+has_added_app=1+and+uid+IN(SELECT+uid2+FROM+friend+WHERE+uid1=$facebookid)&access_token=$token;
Stefano — October 20th, 2011 at 4:52 pmJust in case anyone lands up here, has_added_app has been deprecated use is_app_user instead:
SELECT uid FROM user WHERE is_app_user=$app_id and uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Ms. Roy — May 24th, 2012 at 2:36 am