我经历了大量的谷歌搜索,并在获取 Facebook 群组列表时遇到了绊脚石。第一个调用转到 api 以获取用户帐户关联的组对象:
$this->groups = $this->facebook->api('/me/groups');
这适用于基本信息
{
"version": 1,
"name": "Email Friends",
"id": "12345",
"unread": 1,
"bookmark_order": 12
},
为了深入挖掘,我需要以下 id:
https://graph.facebook.com/374541109272246?access_token=3fasdfvartfawefwefq
这让我得到了组信息:
{
"id": "12345",
"version": 1,
"owner": {
"name": "someone",
"id": "123456"
},
"name": "Email Friends",
"privacy": "OPEN",
"icon": "https://s-static.ak.facebook.com/someimage.png",
"updated_time": "2012-09-18T01:25:20+0000",
"email": "123435@groups.facebook.com"
}
通过浏览器使用单个查询拉多个组很简单:
https://graph.facebook.com/?ids=098765,32113,12345,?access_token=3fasdfvartfawefwefq
那么使用 API 或 FQL,我如何能够一次提取多个组的信息?
$this->getFBData("groups");
$groupsData = '<div id="gtooltip">';
foreach ($this->groups['data'] as $data)
{ $gids .= $data['id'] .','; }
try{
$grpData = $this->facebook->api("/?ids=$gids");
}catch(FacebookApiException $e){
error_log($e);
return MsgBox(_t("$e"."$gids"));
}
我尝试了多种变体,facebook->api("/?ids=$gids");
但无法使其正常工作。