Replacement for old GetAppUsers call to see a user's friends who use my application?
Asked Answered
L

2

10

One immensely useful call in the old REST API is Friends.getAppUsers. This call returns all your friends that are using an application. Sadly, this is not in the Open Graph API. There is a good Stack Overflow post about it, Facebook 'Friends.getAppUsers' using Graph API.

However, it is possible to use the Graph API to make FQL calls as can be seen here in the Graph API explorer.

I thought that maybe I could make the following call using the C# SDK:

fb.GetAsync("fql/?q=SELECT uid,username, is_app_user FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user=1");

However, this returned an error. Is there a way to work around the lack of the GetAppUsers call using the existing C# SDK?

Leaguer answered 31/10, 2011 at 16:32 Comment(0)
J
30

The replacement API call for users.isAppUser is a simple call to /me/?fields=installed This also works for a user's friends so by extension it's a replacement for friends.getAppUsers.

I tried this both with the App Access Token and a regular User Access token. Make an API call to /{user id}/friends?fields=installed - The return looks like this:

{
  "data": [
    {
      "id": "{FRIEND_UID_1}"
    }, 
    {
      "id": "{FRIEND_UID_2}"
    }, 
    // etc...
    {
      "installed": true, 
      "id": "{FRIEND_UID_X}"
     }

//SNIP

You can use the presence, or lack therof, of the installed:true to determine which of the user's friends use your app.

If that doesn't work for you for some reason; won't you already have a list of uids of users of your app in your own database? You could just retrieve the user's full list of friends and compare it to your own records of who's using your app.

Jit answered 31/10, 2011 at 16:32 Comment(1)
As an aside, the FQL in your original question basically looks fine to me; what error did you get back? It may be possible to use something very similar to get your answer, it could just be a formatting problem or somethingJit
S
0

There is a problem with your path.

uid1 = me()) AND is_app_user=1

= is not URL encoded correctly. Replace = with %3d.

uid1 %3d me()) AND is_app_user%3d1

This might look ugly. So a better way would be to use the Query/QueryAsync method:

fb.QueryAsync("SELECT uid,username, is_app_user FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user=1");

If you are using v5.2.1 or earlier, Query will use the legacy REST API. If you are using a version later than v5.3.1, it will use the Graph API to execute the FQL query.

Shemeka answered 1/11, 2011 at 10:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.