Facebook : Get List of Online Friends Using Graph

2019-07-06 09:14发布

问题:


I want to Get list of users online without Facebook SDK.My fql Query is as below

 $fql = "SELECT uid, name, pic_square, online_presence
            FROM user
            WHERE online_presence IN ('active', 'idle')
            AND uid IN (
                SELECT uid2 FROM friend WHERE uid1 = $user
            )";

And my graph URl is

https://graph.facebook.com/fql?q=SELECT uid, name, pic_square, online_presence FROM user WHERE online_presence IN ('active', 'idle') AND uid IN (SELECT uid2 FROM friend WHERE uid1 = 1234)&access_token=xxxxxxtokenxxxxx&method=GET

But Above Url returning null data.

{
   "data": [

   ]
}

Note: my token have friends_online_presence permission .I have 40 users online.

回答1:

You need user_online_presence or friends_online_presence permissions to view online_presence. (see http://developers.facebook.com/docs/reference/fql/user)

Without these permissions you'll receive online_presence as null, and nothing will be filtered by this part of WHERE: online_presence IN ('active', 'idle')

If you'll remove this restriction from your query, you'll see the list of friends with their statuses (or nulls if you don't have this permission)