0
$query = 'SELECT friend_count FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) and sex='male'';

$url = "https://graph.facebook.com/fql?q=" . urlencode($query) . 
     "&access_token=" . $access_token;
$data = json_decode( file_get_contents ($url));
$boys = count($data[data]);
echo $boys;

我已经尝试过这种方法,但无法得到想要的结果......我想做一个这样的应用程序

4

2 回答 2

1

不幸的是,FQL 不支持COUNT()你需要的 SQL 函数,这里。

您必须检索朋友的性别列表并遍历它们。

在 FQL 中:SELECT sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

图 API:https://graph.facebook.com/me/friends?fields=gender

于 2012-09-16T13:33:15.980 回答
-2
{
   "error": {
      "message": "An active access token must be used to query information about the current user.",
      "type": "OAuthException",
      "code": 2500,
      "fbtrace_id": "FJgpERmm460"
   }
}
于 2017-04-01T19:25:39.897 回答