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 Groups

Problem

I need to retrieve a specific user’s groups using FQL.

Solution

You can’t get a user’s groups without using both the group and group_member tables:

SELECT name FROM group WHERE gid IN (SELECT gid FROM group_member WHERE uid = $uid);

Discussion

If the current loggedinuser doesn’t have permission to see the groups that uid is in, you’ll get an empty set.

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