5

这是我的fql:

$fql = "SELECT uid, name, online_presence, status 
         FROM user 
        WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = '".$user_id."') ";

online_presence值始终返回null

4

2 回答 2

0

您的查询中有错误...

只需更换

WHERE uid IN

WHERE 2 IN

询问

$fql = "SELECT uid, name, online_presence, status 
         FROM user 
        WHERE 2 IN ( SELECT uid2 FROM friend WHERE uid1 = '".$user_id."') ";

SQLFiddle 演示

于 2013-04-08T20:10:19.140 回答
0

如果您尝试在没有 Facebook 访问令牌的情况下查询 Facebook,您将无法检索online_presence键值。例如:

SELECT uid, name, online_presence, status FROM user WHERE uid IN (4,5,6)

如果没有设置访问令牌,则返回:

{
  "data": [
    {
      "uid": 4, 
      "name": "Mark Zuckerberg", 
      "online_presence": "", 
      "status": null
    }, 
    {
      "uid": 5, 
      "name": "Chris Hughes", 
      "online_presence": "", 
      "status": null
    }, 
    {
      "uid": 6, 
      "name": "Dustin Moskovitz", 
      "online_presence": "", 
      "status": null
    }
  ]
}

然而,使用访问令牌集,返回:

{
  "data": [
    {
      "uid": 4, 
      "name": "Mark Zuckerberg", 
      "online_presence": "offline", 
      "status": null
    }, 
    {
      "uid": 5, 
      "name": "Chris Hughes", 
      "online_presence": "offline", 
      "status": null
    }, 
    {
      "uid": 6, 
      "name": "Dustin Moskovitz", 
      "online_presence": "offline", 
      "status": null
    }
  ]
}

确保您设置了有效的 Facebook 访问令牌(在 PHP 中使用官方 Facebook SDK,如下所示:)$facebook->setAccessToken($your_access_token);并具有访问数据的适当权限。

权限可能是null两个响应中返回“状态”的原因。我和扎克伯格先生不是朋友。

于 2013-12-27T16:54:09.400 回答