App Friends

Problem

I need to find all of the friends of a specific user who have already installed my application.

Solution

SELECT uid FROM user WHERE has_added_app = 1 AND uid IN (SELECT
 uid2 FROM friend WHERE uid1 = $user);

Discussion

This particularly comes in handy when you’re displaying an fb:multi-friend-selector control in FBML and want to exclude friends of the current loggedinuser who have already installed your app (see Invitations and Requests).

Get Facebook Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.