Reputation: 57
Could someone point me in the right direction to how I can get a list of all the groups a specific user is connected to using the facebook graph api?
I have this:
$groups = $facebook->api( '/me/groups', 'GET', array( 'access_token=' => $membertoken ) );
If I use print_r($groups)
I can see the array is returning all the groups, but how can I seperate the array to list just the group names and group ID into seperate strings so I can use them in a database etc?
Upvotes: 3
Views: 10815
Reputation: 11852
Try this:
print "<h2>Here are the groups you follow:</h2>\n<ul>";
foreach ($groups['data'] as $group) {
$group_name = $group['name'];
$group_id = $group['id'];
printf("<li>%s - ID = %s</li>\n", $group_name, $group_id);
}
print "</ul>";
Upvotes: 1