8

I have an application using the Graph API. I have it creating events for the user, but would like to let the user invite their friends from our site instead of having to go to the events Facebook page. Does anyone know of the request I have to send the friends' IDs too to invite them like with the old API? Or if it even exists? I am finding a lot of the finer details in the API documentation are vague. Thank you!

Also, side question, can you send an event photo with the create POST? I see no mention on how to submit a photo with the event creation. Thanks.

Kara
  • 6,115
  • 16
  • 50
  • 57
gokujou
  • 1,482
  • 3
  • 15
  • 27

5 Answers5

7

I actually was able to get an answer from the Facebook team and they just told me to use the old API through the new PHP interface. They have yet to convert this functionality and don't know if it will be converted.

Edit:

Here is the code I used to invite friends after I got the IDs from the new api ($id_array). This is applied in a wrapper around the PHP Facebook object I used to hold all my Facebook specific code.

    $fb = new FacebookGraph(array(
        'appId' => 'xxxx',
        'secret' => 'xxxx',
        'cookie' => true,
    ));
    $fb->api(array(
        'method' => 'events.invite',
        'eid' => $event_id,
        'uids' => $id_array,
        'personal_message' => $message,
    ));
gokujou
  • 1,482
  • 3
  • 15
  • 27
  • Will you provide some sample code of inviting a users friends to an event using the old API? The question really isn't answered yet. – Myer Nov 12 '10 at 18:20
  • Just want to add - the REST API doesn't support 'impersonated' tokens, i.e. access tokens representing pages or businesses. So it's currently impossible to invite people to an event with an impersonated token until this is implemented in the graph. – Shaun Budhram Jun 02 '11 at 08:03
  • Changed my selected answer due to changes in the Graph API and this actually being supported now. – gokujou Feb 27 '12 at 07:01
6

This is actually possible with the Graph API, specifically the invited connection of the event's object:

POST /EVENT_ID/invited/USER_ID

Invite a user to an event. Returns true if the request is successful.

POST /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3

Invite multiple users to an event. Returns true if the request is successful.

You'll need the create_event permission. More info is available in this post.

ifaour
  • 38,035
  • 12
  • 72
  • 79
  • 1
    You are correct, back when I originally posted this question the feature you mention was still a year from being released though. Thank you for the update to the post. – gokujou Feb 27 '12 at 07:00
  • @gokujou, true...but since this question has so many views. An updated answer was needed! Thanks for the accept! – ifaour Feb 27 '12 at 07:06
  • I know this is a very old post but does anyone know how to invite a friend in todays Graph API 2.7 ? _(#12) invited field is deprecated for versions v2.4 and higher_ – user3191334 Mar 02 '17 at 21:42
  • 1
    Spoiler alert: Facebook removed this functionality completely in 2015. There's now *no way* to get your code to invite even 1 member to an event. Ridiculous.... – Mike Gledhill Jul 26 '17 at 19:36
2

The possibility to invite users to an Event was removed in v2.4 of the Graph API:

The Event node no longer supports GET operations on the endpoints /v2.4/{event_id}/invited, /v2.4/{event_id}/likes, or /v2.4/{event_id}/sharedposts.

There is no way to invite users to an Event anymore, you have to use facebook.com instead.

Community
  • 1
  • 1
andyrandy
  • 72,880
  • 8
  • 113
  • 130
0

you can also use javascript sdk:

var inviteCallback = function(result) {
    console.log(result);
};
var event_intives = {
    method: 'events.invite',
    eid: event_id,
    uids: friends_list_array,
    personal_message: 'custom request message'
};
FB.api(event_intives, inviteCallback);

if all ok, it should log 'true'

0

see Inviting selected users to Facebook-Event (via Graph API)

Facebook now has a graph api for inviting friends to events.

http://developers.facebook.com/docs/reference/api/event/

invited

Create

You can invite users to an event by issuing an HTTP POST to /EVENT_ID/invited/USER_ID. You can invite multiple users by issuing an HTTP POST to /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3. Both of these require the create_event permission and return true if the invite is successful.

And the answer to your side question is here: Attach image to Facebook event (php sdk, rest or graph api)

Community
  • 1
  • 1
Brad
  • 556
  • 4
  • 10