How can I get a user's presence using Facebook php sdk?

I am using the latest PHP sdk for Facebook to grant my app permissions. This is how I granted the app permissions.

$extra_params = array('scope' => 'email, read_mailbox,friends_online_presence,xmpp_login,publish_actions', ); $loginUrl = $facebook->getLoginUrl($extra_params);

How can I get the users online alone? When I use the code below I get all users despite others being offline

$user_profile = $facebook->api('/me/friends'); var_dump($user_profile);

and when I use this I get an empty array.

$user_profile = $facebook->api('/me/friends/online'); var_dump($user_profile);

-------------Problems Reply------------

After a Google search I came across an fql that works fine. The code is below

$params = array(
'method' => 'fql.query',
'query' => "SELECT uid,name,online_presence FROM user WHERE
online_presence = 'active'
AND uid IN (
SELECT uid2 FROM friend where uid1 = me()
)"
);

$user_profile = $facebook->api($params);
var_dump($user_profile);

It works like charm.

Category:php Views:0 Time:2013-10-17

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.184 (s). 11 q(s)