这是我的fql:
$fql = "SELECT uid, name, online_presence, status
FROM user
WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = '".$user_id."') ";
online_presence
值始终返回null
。
答案 0 :(得分: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."') ";
答案 1 :(得分: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
的原因。我不是扎克伯格先生的朋友。