且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用图形API获取用户的Facebook群组列表

更新时间:2022-10-31 13:38:16

尝试这样:

  print< h2>您遵循的群组:< / h2> \\\
< ul>;
foreach($ groups ['data'] as $ group){
$ group_name = $ group ['name'];
$ group_id = $ group ['id'];
printf(< li>%s - ID =%s< / li> \\\
,$ group_name,$ group_id);
}
print< / ul>;


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?

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>";