O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Get Friends Who Use My App

Problem

I need to retrieve all of the current loggedinuser’s friends who already have my app installed.

Solution

Use the Friends.getAppUsers() method:

$friends = $facebook->api_client->friends_getAppUsers();

This method has no parameters, and it can be called only for the combination of the current loggedinuser and your application.

Discussion

Friends.getAppUsers() returns an array of uids of the friends who have your app installed. It is against the terms of use of Facebook Platform to store the returned values from this call.

FQL equivalent

If you’d prefer to use FQL to access friends, the equivalent query is:

SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=$uid)
 AND is_app_user

See App Friends for more information.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required