Search code examples
facebookfacebook-graph-apicustom-action

Querying custom actions published by other users


It is my understanding that a list of a users published custom action in an app can be queried with the following URL.

https://graph.facebook.com/me/gym:workedout?access_token=<accessToken>

In this case the app is "gym" and the custom action is "workedout".

My question is; can a user query for custom actions that we're published by other users, and if so how?


Solution

  • Yes, your app can read a user's friends' activity in any Open Graph app, provided they grant you the appropriate permission. Replace 'me' in your call above with the user ID of your app's user's friend whose activity you want to query - you'll need the appropriate permission (friends_actions:[APP_NAMESPACE])

    Short version,using 'gym' and 'workedout' as an example request the friends_actions:gym permission from the user, and then query /<user id>/gym:workedout

    It has to be done for specific friends, not on the /friends connection, so for a given user, the best way to see 'all activity published by their friends (and visible to that user (you'd be surprised how many people don't consider this..)), is to:

    • Request user_actions:APP_NAMESPACE and friends_actions:APP_NAMESPACE permission from the user
    • Get a list of that user's friends who use the app. If you're doing this in the same app, you can do so by calling /me/friends?fields=installed and looking for the users with installed: true
    • If you're doing this from a DIFFERENT app, you'll need the user to tell you which of their friends use the app if you want to optimise your query, otherwise you'll need to break their entire friends list into batches before doing the next step
    • Request a list of the friends' actions in that app by calling /APP_NAMESPACE:ACTION_NAME?ids=COMMA_SEPARATED_LIST_OF_UIDS (example: /gym:workedout?ids=4,5,1234567889,1111111111)
      • Caveat: you also need to know what the action is called in the API; i'm not sure of a good way to do this if it's for an app other than your own (anyone got an idea?)