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.
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.