0

当前我正在执行此 FQL 以获取用户信息
请帮助我将所有查询合并为一个 [我想通过编写单个 FQL 来获取 4 个数组中的所有信息]!

$pics=array();
$ids=array();
$names=array();
$sexs=array();
$i=0;

$fql = "SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ";
$fUIDS = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
foreach($fUIDS as $data)
{
 $ids[$i]=$data['uid'];
 $i++;
}
?>
<?php
$fql = "SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())     ";
$fNames = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
$i=0;
foreach($fNames as $data)
{
 $names[$i]=$data['name'];
 $i++;
}

$fql = "SELECT pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ";
$fPics = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
$i=0;
foreach($fPics as $data)
{
 $pics[$i]=$data['pic_square'];
 $i++;
}

$fql = "SELECT sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
$fSexs = $facebook->api(array(
    'method' => 'fql.query',
    'query' =>$fql,
    ));
    $i=0;
    foreach($fSexs as $data)
    {
     $sexs[$i]=$data['sex'];
     $i++;
    }
?>
4

2 回答 2

1

如果没有任何 FQL 的特定知识,我会冒险进行这个猜测;它似乎是 SQL,您通常一次只能指定多个字段...

$pics  = array();
$ids   = array();
$names = array();
$sexs  = array();

$fql   = 'SELECT uid, name, pic_square, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())';
$data  = $facebook->api(array('method' => 'fql.query','query' => $fql));
foreach ($data as $datum) {
    $pics[]  = $datum['pic_square'];
    $ids[]   = $datum['uid'];
    $names[] = $datum['name'];
    $sexs[]  = $datum['sex'];
}
于 2011-06-01T04:04:35.727 回答
1

似乎您想收集用户的 user_id、个人资料图片 url 和性别。那为什么要运行 3 个查询呢?只运行一次并从返回的数组中提取值。

$fql = "SELECT uid, name, pic_square, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
于 2011-06-01T04:06:49.537 回答