这是我的fql:
$fql = "SELECT uid, name, online_presence, status
FROM user
WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = '".$user_id."') ";
该online_presence
值始终返回null
。
这是我的fql:
$fql = "SELECT uid, name, online_presence, status
FROM user
WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = '".$user_id."') ";
该online_presence
值始终返回null
。
您的查询中有错误...
只需更换
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."') ";
如果您尝试在没有 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
两个响应中返回“状态”的原因。我和扎克伯格先生不是朋友。