I keep record of all users of my app in local, MySQL database. I have all the relevant information required to get user online presence status [UID, access_token
and granted extended permission
].
How do I get online presence status of all users?
The approach I am using at the moment, is to query each user separately:
$facebook->api(array
(
'access_token' => 'x',
'method' => 'fql.query',
'query' => "SELECT uid, name, first_name, last_name, online_presence FROM user WHERE uid = x"
));
But this is time taking procedure with 150 users. I am not even talking about 400+ or 1000+.
p.s. multiquery didn't work for me, because asking user presence requires to provide the access_token
.
My solution:
SELECT name, uid, online_presence FROM user WHERE uid=me()
For all online
SELECT name,uid FROM user WHERE
online_presence IN ('active', 'idle')
With friend
SELECT name,uid FROM user WHERE
online_presence IN ('active', 'idle')
AND uid IN (
SELECT uid2 FROM friend WHERE uid1 = $user_id
)
This isn't really an option and in terms of why you would need this data, it is not readily apparent as to the purpose of it. Maybe if you could provide more information, a different solution would be available.
Another viable option is to rely on the Chat API. This will tell you all the users that are set to online status in Facebook Chat. This wouldn't be too reliable as this includes users accessing solely the Facebook Chat(desktop/mobile software) as opposed to the actual website users.