lenfontes
lenfontes

Reputation: 53

Facebook RSVP to an event using jQuery / JavaScript

I've been trying this without success. I've already gotten the user's authentication with event_rsvp permissions, as well as an access token, yet each time I try to RSVP to an event, it doesn't work. I call the following on a button click:

function attendingEvent() {
    var url = 'https://graph.facebook.com/'+eventid+'/attending/'+userid+'?access_token='+accessToken;
    $.post(url, function(data) {
        $('#event_info').html(data);
    });
}

For some reason I'm not even getting the "callback". What am I doing wrong?

Upvotes: 2

Views: 1766

Answers (2)

Igy
Igy

Reputation: 43816

That should work, but as Colin says make sure you're POSTing the request.

A GET request to /{event id}/attending/{user id} returns an array of user name and user id if the user is already attending the event, and an empty array otherwise

Try the Graph API Explorer to debug this

Upvotes: 2

Colin Smillie
Colin Smillie

Reputation: 441

You may need to include the POST method by adding it like:

https://graph.facebook.com/'+eventid+'/attending/'+userid+'?access_token='+accessToken&method=POST

I would also look at the access_token. I believe if you receive no response its an access token issue, you should get an error response for most other conditions.

Try copying your values into the FB test console here:

http://developers.facebook.com/docs/reference/rest/events.rsvp/

Below the RSVP function details. It may reveal more about an access token issue.

Upvotes: 1

Related Questions