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

Retrieving a User’s Friends

Problem

I need to retrieve all of a specific user’s friends using FQL.

Solution

This is a really simple query:

SELECT uid2 FROM friend WHERE uid1 = $uid;

Discussion

Luckily for FQL users everywhere, this query returns exactly the same result if you run it the other way around:

SELECT uid1 FROM friend WHERE uid2 = $uid;

You can run this query only when you’re looking for the friends of the current loggedinuser, or you’ll get an “Error 604: Can’t lookup all friends of 12345; only for the logged in user” error (see 600 Errors for more info).

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