Checking Whether Two Users are Friends
Problem
I need to check to see whether two users are friends using FQL.
Solution
If this query returns a result, user1
and user2
are friends:
SELECT uid1 FROM friend WHERE uid1 = $user1 AND uid2 = $user2;
Discussion
There are no privacy restrictions on this query in terms of errors, but you
will get back an empty set if the current loggedinuser
isn’t allowed to see the
friends for one of the two users.
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.