Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Facebook RSVP using the JS SDK
<html>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '721489701236648',
status : true,
xfbml : true
});
FB.login(function(){
// This is a Graph API called in the context of the logged-in user
FB.api("/300843286737953/attending", function(r){
console.log("attending", r)
});
// RSVP
FB.api("/300843286737953/attending", "POST", function(r){
console.log("rsvp", r)
});
// Un-RSVP
FB.api("/300843286737953/attending", "DELETE", function(r){
console.log("un-rsvp", r)
});
}, {scope: "rsvp_event"});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</body>
</html>
@Bahtx

This comment has been minimized.

Copy link

@Bahtx Bahtx commented Apr 9, 2014

What does this allow us to do on facebook?

@scottburton11

This comment has been minimized.

Copy link
Owner Author

@scottburton11 scottburton11 commented Apr 9, 2014

Isolated example, but generally FB.api inside the FB.login callback allows arbitrary Graph API requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment