Reputation: 9
I have been playing around with the Graph API to get a list of the user's friends who have installed my App.
Using this:
if ($user) {
try {
$friendsapp = $facebook->api('/me/friends?fields=installed');
} catch (FacebookApiException $e) {
echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
$user = null;
}
}
I have just created the app and I know only myself, and one other, have installed it. When I log on as the user, I get a very large list of friends for this call. Any ideas on what I'm doing wrong?
I should only get a return with the one other user as being a friend who has installed the app.
Thanks! ...and yes, I'm a noob with integrating Facebook into websites.
Upvotes: 1
Views: 1751
Reputation: 2135
This is because using graphi API returns all the objects you ask for. Specifying the fields parameter is simply asking the API to specifically return that attribute for all the objects that are returned. There is really no way to narrow down the results further. FQL on the other hand is a query language that allows you to narrow down the result set to your liking using standard where clauses and the like.
Upvotes: 0
Reputation: 403
Simple FQL should be enough:
SELECT uid FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Upvotes: 1