Skip to content

Instantly share code, notes, and snippets.

@scottburton11
Created April 9, 2014 02:50
Show Gist options
  • Save scottburton11/10221751 to your computer and use it in GitHub Desktop.
Save scottburton11/10221751 to your computer and use it in GitHub Desktop.
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>
@scottburton11
Copy link
Author

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