Created
April 9, 2014 02:50
-
-
Save scottburton11/10221751 to your computer and use it in GitHub Desktop.
Facebook RSVP using the JS SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Isolated example, but generally
FB.apiinside theFB.logincallback allows arbitrary Graph API requests.