How to invite friends to facebook app via the Graph API

13,511

So it turns out, thank to CBroe's comment that it is not possible to invite via the Graph API (I wish it were clearer in the documentation).

It is not necessary, however, to use the friend select dialog. It is possible to generate your own list of friends using either the graph api, server-side or client-side and produce a confirmation box by using the JS SDK like so:

$('form').on('submit', function(e) {
  e.preventDefault();
  var userIds = $(this).find('input:checkbox:checked').map(function() {
    return parseInt($(this).val(),10);
  }).get();
  FB.ui({method: 'apprequests',
    message: 'Check this app out!',
    to: userIds
  });
});
Share:
13,511
Marc Greenstock
Author by

Marc Greenstock

Updated on June 05, 2022

Comments

  • Marc Greenstock
    Marc Greenstock almost 2 years

    I hope this hasn't been answered before, I have looked everywhere but I have come up empty. There are a few similar questions here but none have the answer I am looking for:

    I want to send a Facebook Canvas App invite to the OAuth signed in user's friends via the Graph API.

    I seem to be going around in circles with the documentation as everything points to the JS SDK dialog (https://developers.facebook.com/docs/reference/dialogs/requests/). The end result is the same where a notification will materialise for the invited friends with "{User} has invited you to try {App name}" but I don't want to use the JS dialog.

    It appears I should be looking here https://developers.facebook.com/docs/games/notifications however when I try to send a notification, I can only send to users who are already using the app. This tip seems to suggest the limitation I am seeing however the language used is confusing:

    All notifications from an app are treated the same way, independent of how they're sent, via this API or as a person-to-person request. People won't see a first receipt prompt for invites, that is they have not authorized the app and a friend is simply inviting them to try the app.

    Can anyone help?

  • natario
    natario over 7 years
    sorry if I ask, 2-3 years passed , do you know if it’s still impossible to invite without the SDK?