fql查询失败 - 怀疑auth问题

时间:2012-03-06 20:46:47

标签: facebook facebook-fql

在页面中,如果我进行测试fql查询,它可以工作:

$fql = 'SELECT name from user where uid = ' . $user_id;
        $ret_obj = $facebook->api(array(
                                   'method' => 'fql.query',
                                   'query' => $fql,
                                 ));

        echo '<pre>Name: ' . $ret_obj[0]['name'] . '</pre>';

但是,如果我尝试运行此查询,则会失败:

$fql2 = 'SELECT uid, name, pic_square FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex =male';
$ret_obj2 = $facebook->api(array(
                           'method' => 'fql.query',
                           'query' => $fql2,
                         ));


echo '<pre>Name: ' . $ret_obj2[0]['name'] . '</pre>';

我怀疑这是一个auth问题,因为相同的fql查询在图api测试工具中有效!

如果你想查看完整的php代码,这是这个页面上的第二个例子: https://developers.facebook.com/docs/reference/php/facebook-api/

2 个答案:

答案 0 :(得分:0)

您只需要此查询的基本权限,因此这不是问题。尝试在“男性”周围添加双引号:

$fql2 = 'SELECT uid, name, pic_square FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex="male"';

答案 1 :(得分:0)

感谢支持人员,查询因两个原因无效:

1)我忘记了;在声明结束后

2)在我的代码中,我使用了

`SELECT uid, name, pic_square, FROM` 

而不是

`SELECT uid, name, pic_square FROM`