我是 PHP 和 FQL 的新手。我知道它需要如何完成,但不知道代码。创建一个用户只能在框中看到异性的应用程序。
我开始获取用户的姓名、性别和朋友 ID。现在我需要帮助运行 FQL 并获取所有朋友的性别,并将异性的名字插入 .
<?php
$fbuser = $facebook->api('/me');//getting users data
$friends = $facebook->api('/me/friends'); //getting friends data (only gives id and name)
$userName = $fbuser['name'];//getting users name
$userGender = $fbuser['gender'];//getting users gender
$friendsId = array();//empyt array to insert friends id
foreach ($friends['data'] as $value);{ //loop
array_push($friendsId, $value['id']); // not sure if this correct
$friendsGender = friendsGender ;//run FQL to get the friends gender using the id
//conditional Statement, if users and friends gender is not same insert the friends name in <select>
?>
我做了以下但没有奏效。我的第二行脚本正确吗?
$friendsInfo = $facebook->api('/me/friends', array('fields' => 'id,name,gender'));
$friendsGender = $friendsInfo['gender'];
echo $friendsGender;