得到女性朋友脸书

时间:2014-10-08 02:10:36

标签: facebook facebook-graph-api facebook-fql

我想得到女性朋友facebook

$fql = "https://graph.facebook.com/me/fql?q=SELECT sex, uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = 'female' LIMIT 10&access_token=$access_token";
$fqlresult = file_get_contents($fql); 
$f = json_decode($fqlresult, true);
$friends1 = $f['data']['1']['uid'];

我尝试了这个但没有返回任何东西。

2 个答案:

答案 0 :(得分:0)

您可以尝试使用graph api获取朋友的性别,并使用php代码过滤以获取女性朋友:

$query =  "https://graph.facebook.com/v2.1/me?fields=friends{gender,name}&acess_token=$your_access_token";
$results = file_get_contents($query);
$freinds = json_decode($results , true);
foreach($freinds as $friend)
{
      if($friend['gender']=='female')
      {
          echo $friend['name'].'<br>';
      }

}   

答案 1 :(得分:0)

FQL查询SELECT sex, uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = 'female' LIMIT 10

是正确的并且有效(我试过了),您的整体API查询需要类似

https://graph.facebook.com/fql?q=

不是

https://graph.facebook.com/me/fql?q=

删除me