Facebook 'Friends.getAppUsers' using Graph API

后端 未结 8 1765
盖世英雄少女心
盖世英雄少女心 2020-11-27 09:29

I have an application that uses the old REST API call Friends.getAppUsers to get the list of friends for the current user that have authorized my application.

相关标签:
8条回答
  • 2020-11-27 09:54

    This can be done with FQL.

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

    QED!

    0 讨论(0)
  • 2020-11-27 09:57

    Yes, the Graph API is horribly documented. I don't see any documentation for an "application" type, but they do reference an application's info in the docs:

    https://graph.facebook.com/2439131959

    So, perhaps you can get the application's members using the Group syntax?

    https://graph.facebook.com/2439131959/members

    You'll need an authenticated session to test it. Otherwise, it looks like Facebook is pushing us to use FQL to send queries directly:

    http://developers.facebook.com/docs/reference/fql/application

    You can execute FQL queries by fetching https://api.facebook.com/method/fql.query?query=QUERY. You can specify a response format as either XML or JSON with the format query parameter.

    So you can pass a FQL query to get information about your application.

    0 讨论(0)
  • 2020-11-27 10:04

    The workaround is to do the filtering yourself. Presumably, you have all the uid's of the users who have signed up for your application sitting in your own database. So first get all the users' friends' uids, and select the users from your database who have matching uids.

    The new Facebook Graph API program seems very poorly executed and not quite thought through. It seems they rushed to publish it for Facebook f8 before it was mature, and lots of functionality is missing that was available before.

    0 讨论(0)
  • 2020-11-27 10:09

    I searched around for a while, and I too thought this wasn't possible using Graph API.

    However, I posted a similar question, Replacement for old GetAppUsers call to see a user's friends who use my application?, for the specific API I was using and was given a great general answer.

    https://graph.facebook.com/me/friends?fields=installed
    

    or more generally

    https://graph.facebook.com/{user id}/friends?fields=installed
    

    This returns all friends, with the additional field "installed=true" for those friends who use the application.

    Here is it working in the Graph API Explorer:

    0 讨论(0)
  • 2020-11-27 10:09

    I've done a lot of investigations on this issue. From what I can tell, there is no way to do Friends.getAppUsers using Graph API. The latest SDKs provided by Facebook all use the old REST API to get friends using the application.

    0 讨论(0)
  • 2020-11-27 10:11

    You can still call the old REST API's in the new Graph API. That is prefectly valid.

    An alternative way is to use FQL to get the application user's friends.

    I'm not sure if there's a way to do this using just Graph API.

    0 讨论(0)
提交回复
热议问题