0

i want to get a user's friends who are using the app too. I currently achieve this by getting all the friends

FB.api('/me/friends?fields=id,name,updated_time&date_format=U&<?=$access_token?>',
    { limit: 500 },
        function(response) {
            alert(response.data.length + ' friends');
});

and then checking if I can see them in my database, using an ajax call.

The thing that this isn't really what I need, because:

  • This way I will consider users that are no longer using the app
  • It makes difficult to present the friends as I first have them all in an array and then, with delay, this array is updated and so on.

So the question is, can I get this information from the Graph API directly? (something like is_app_user = 1 or 0)

Just code
  • 13,553
  • 10
  • 51
  • 93
Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378

1 Answers1

1

You can either add the installed field when asking for friends, like so:

/USER_ID/friends?fields=installed

and only the friends who installed your app will have this field set.

You can also use FQL intead:

SELECT uid
FROM user  
WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

I prefer the FQL version, since it returns the short list from the start.

Guy Tomer
  • 66
  • 5