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 Friend Lists

Problem

I need to retrieve all of the friend lists for the current loggedinuser.

Solution

Use the Friends.getLists() method:

$friendLists = $facebook->api_client->friends_getLists();

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

Discussion

Friends.getLists() returns an array of the flids (friend list IDs) for the current loggedinuser. You can retrieve the members of a friend list by calling Friends.get() and passing in the flid (see Get Friends).

You’re allowed to store the returned friend lists, but you should check them periodically because changes users make won’t be reported back to you. Friend lists are considered private, so you can’t share this information with anyone else.

FQL equivalent

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

SELECT flid, name FROM friendlist WHERE owner = $uid;

See Retrieving a User’s Friend Lists 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