这是我的Facebook UID:1053557928。如果我在资源管理器中运行此FQL,我会得到我期望的结果。更准确地说,我得到了“生日”字段。我有正确的权限“user_birthday”。
SELECT uid, birthday, name
FROM user
WHERE uid IN (
SELECT uid2
FROM friend
WHERE uid1='1053557928'
) limit 3
如果我从Symfony2命令控制台运行相同的查询,我会得到结果,但没有字段生日。我肯定有权限。
array(3) {
[0] =>
array(3) {
'uid' =>
string(9) "0987654321234567890"
'birthday' =>
NULL
'name' =>
string(12) "Middle John"
}
[1] =>
array(3) {
'uid' =>
string(9) "0987654321234567890"
'birthday' =>
NULL
'name' =>
string(15) "Short John"
}
[2] =>
array(3) {
'uid' =>
string(9) "0987654321234567890"
'birthday' =>
NULL
'name' =>
string(12) "Long John"
}
}
另外,如果我尝试执行:
$accessToken = $this->container->getParameter('facebook_app_token');
$uid1 = '1053557928';
$wishInterval = new WishDates();
$startSearchDate = clone $wishInterval->getDateFrom();
$fqlDates = "";
for ($i = 0; $i <= 6; $i++) {
$month = $startSearchDate->format("F");
$day = (int)$startSearchDate->format("d");
if ($fqlDates != "") {
$fqlDates .= " OR ";
}
$fqlDates .= " strpos(birthday, \"{$month} {$day},\")>=0";
$startSearchDate->modify("+1 days");
}
$fql = "SELECT uid, birthday, name " .
" FROM user " .
" WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='$uid1') limit 3";
// Interrogo Facebook
$config = array(
'appId' => $this->container->getParameter('facebook_app_id'),
'secret' => $this->container->getParameter('facebook_client_secret'),
'allowSignedRequest' => true
);
$facebook = new Facebook($config);
$query = array(
'method' => 'fql.query',
'query' => $fql,
'access_token' => $accessToken
);
$return = $facebook->api($query);
我得到“需要用户会话”。但我登录Facebook。生成的查询($ fql)在facebook explorer API中仍然可以正常工作。但是此代码返回数组生日。会发生什么?