如何获得男性和女性朋友的数量以及他们的facebook应用程序百分比是多少

时间:2012-09-16 08:46:08

标签: facebook facebook-fql

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

我尝试过这种方法但无法获得理想的效果...... 我想制作一个这样的应用

2 个答案:

答案 0 :(得分:1)

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

您必须检索朋友的性别列表并循环播放。

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

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

答案 1 :(得分:-2)

{
   "error": {
      "message": "An active access token must be used to query information about the current user.",
      "type": "OAuthException",
      "code": 2500,
      "fbtrace_id": "FJgpERmm460"
   }
}