如何使用图形API获取用户的Facebook群组列表 [英] How to get a list of facebook groups for a user using graph api

查看:322
本文介绍了如何使用图形API获取用户的Facebook群组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以指出我正确的方向,以便我可以得到一个特定用户使用Facebook图表API连接到的所有组的列表。



我有这个:

  $ groups = $ facebook-> api('/ me / groups','GET',array 'access_token ='=> $ membertoken)); 

如果我使用 print_r($ groups)我可以看到数组正在返回所有的组,但是我如何分离数组只将组名和组ID列为单独的字符串,以便我可以在数据库中使用它们?

解决方案

尝试这样:

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

这篇关于如何使用图形API获取用户的Facebook群组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆