$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;
我尝试过这种方法但无法获得理想的效果...... 我想制作一个这样的应用
答案 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"
}
}