How to discover which friends accepted invites with Facebook API?

Solution 1:

TLDR: Save the response from the actual invite these friends request

As far as I understood the reference you provided:

You can start requesting invite_tokens which I assume you are already able to do.

As answer you get this per invitable_friend:

{
  "id": "AVlzYTkXshfBqLe58zR9tY5dZ7L0wltTUkWKT0Z5V87zkwv-39...", // Invite Token
  "name": "Guy Cross",
  "picture": {
    "data": {
      "is_silhouette": false,
      "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/623782_622770420_2109148508_q.jpg"
    }
  }
}

The page mentions earlier how to do requests in general:

FB.ui({method: 'apprequests',
  message: 'YOUR_MESSAGE_HERE',
  to: 'USER_ID, USER_ID, INVITE_TOKEN' // It says invite token
}, function(response){
  console.log(response);
});

Look at the line with to: You can put invite tokens in there.

Now the response looks like this:

{
  request: 'REQUEST_OBJECT_ID'
  to:[array of USER_IDs]
}

There you got your user ids.


If you go further and either need more informations or want to see who accepted, then you have two options:

  • you can check if the user id has authorized the game
  • when the new user logs in, you can ask for all requests for this new user. There you can track who invited him. GET https://graph.facebook.com/me/apprequests?access_token=[USER ACCESS TOKEN]
  • you save all the data (stated in TLDR) and check everytime a new user joins your game, if the new user id is in your list of requests mentioned.

To check who invited him, you can do check the request_object_id with http://graph.facebook.com/{REQUEST_OBJECT_ID}?access_token=USER_ACCESS_TOKEN of the recieving user and the following response will be:

{
  "id": "REQUEST_OBJECT_ID",
  "application": {
    "name": "APP_DISPLAY_NAME",
    "namespace": "APP_NAMESPACE",
    "id": "APP_ID"
  },
  "to": {
    "name": "RECIPIENT_FULL_NAME",
    "id": "RECIPIENT_USER_ID"
  },
  "from": {
    "name": "SENDER_FULL_NAME",
    "id": "SENDER_USER_ID"
  },
  "message": "ATTACHED_MESSAGE",
  "created_time": "2014-01-17T16:39:00+0000"
}

if you go with the user access token from the sender you get this:

{
  "id": "REQUEST_OBJECT_ID",
  "application": {
    "name": "APP_DISPLAY_NAME",
    "namespace": "APP_NAMESPACE",
    "id": "APP_ID"
  },
  "from": {
    "name": "SENDER_FULL_NAME",
    "id": "SENDER_USER_ID"
  },
  "message": "ATTACHED_MESSAGE",
  "created_time": "2014-01-17T16:39:00+0000"
}

To prevent this, you can specify the user id of the recieving user and get the same answer as from the receiver: https://graph.facebook.com/{REQUEST_OBJECT_ID}_{USER_ID}?access_token={APP_ACCESS_TOKEN}