如何使用Facebook API使用FQL获取在线朋友列表?

如何使用Facebook API使用FQL获取在线朋友列表?

问题描述:

在Facebook上使用Facebook连接Java脚本客户端API登录后,我已经得到了我的朋友列表。我想在给定时间在线的朋友列表。

I have got my friends list after getting logging in on facebook using Facebook connect Java script client API. I want list of my friends that are online at given time.

您可以使用 online_presence 用户$ c>表中的/ code>列,这表示用户当前的Facebook聊天状态。这不是一个万无一失的现在这个用户在线,但它确实有一般目的。此列是一个字符串,其中包含四个可能的值之一:活动 idle offline 错误。查询朋友表与此结果可以产生您请求的结果(在这种情况下,我认为在线是指活动 idle ):

You can use the online_presence column of the user table, which gives the user's current Facebook Chat status. This isn't a foolproof "is this user online right now" but it does serve the general purpose as such. This column is a string which has one of four possible values: active, idle, offline, or error. Querying the friend table in conjunction with this can yield the result you requested (in this case I consider "online" to mean active or idle):

SELECT uid FROM user WHERE
  online_presence IN ('active', 'idle')
  AND uid IN (
    SELECT uid2 FROM friend WHERE uid1 = $user_id
  )

更新:

请注意,您需要 user_status 读取用户状态的权限和 user_online_presence 和/或 friends_online_presence 权限对于 online_presence

Note that you need the user_status permission to read the user's status and user_online_presence and/or friends_online_presence permissions for the online_presence.

感谢https://*.com/users/613631/laphroaig 将其带入( Facebook的在线好友),而 https://*.com/users/570958/roozbeh15 的答案。

Thanks to https://*.com/users/613631/laphroaig for bringing this up (Facebook online friend), and to https://*.com/users/570958/roozbeh15 for his answer.