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 Group Members

Problem

I need to find all of the members of a group.

Solution

Use the Groups.getMembers() method:

$members = $facebook->api_client->groups_getMembers(12345);

where 12345 is the gid (group ID) of your target group.

Description

Groups.getMembers() returns a multidimensional array in which the first level of elements are the four membership types (members, admins, officers, not_replied), each containing the appropriate set of uids representing all of the members of that category whom the current loggedinuser is allowed to see. Note that the members array contains all of the admins and officers but does not overlap with the not_replied array. These lists are not filtered for users of your application, so note that they might contain users who don’t have it installed.

FQL equivalent

If you’d prefer to use FQL to access group members, the equivalent query is:

SELECT uid, gid, positions FROM group_member WHERE gid=$gid

See Listing Table 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