Created
September 7, 2011 13:24
-
-
Save caefer/1200543 to your computer and use it in GitHub Desktop.
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
| <?php | |
| $APP_ID = 'YOUR_APP_ID'; | |
| $APP_SECRET = 'YOUR_APP_SECRET'; | |
| ?> | |
| <html lang="en"> | |
| <head> | |
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
| </head> | |
| <body> | |
| <h1>testing facebook event creation</h1> | |
| <a href="<?php echo $_SERVER['PHP_SELF']; ?>?privacy=OPEN">OPEN</a><br /> | |
| <a href="<?php echo $_SERVER['PHP_SELF']; ?>?privacy=CLOSED">CLOSED</a><br /> | |
| <a href="<?php echo $_SERVER['PHP_SELF']; ?>?privacy=SECRET">SECRET</a><br /> | |
| <hr /> | |
| <?php | |
| if (!isset($_GET['privacy'])) { | |
| echo '<h3>PLEASE PROVIDE A PRIVACY MODE</h3>'.PHP_EOL; | |
| die; | |
| } | |
| $PRIVACY = $_GET['privacy']; | |
| require_once __DIR__.'/php-sdk/src/facebook.php'; | |
| $fb = new Facebook(array( 'appId' => $APP_ID, 'secret' => $APP_SECRET )); | |
| $eventInfo = array( | |
| 'name' => 'a title for an event that is '.strtolower($PRIVACY), | |
| 'start_time' => time()+300, | |
| 'description' => 'some description for this event', | |
| 'privacy_type' => $PRIVACY | |
| ); | |
| $result = $fb->api('/'.$APP_ID.'/events', 'post', $eventInfo); | |
| $eid = $result['id']; | |
| ?> | |
| <div id="fb-root"></div> | |
| <script src="http://connect.facebook.net/en_US/all.js"></script> | |
| <script src="/FB.Permission/src/addon/perm.js"></script> | |
| <script> | |
| FB.init({appId: '<?php echo $APP_ID; ?>', status: true, cookie: true, xfbml: false}); | |
| FB.require(['rsvp_event']); | |
| FB.allow( function(){ FB.api('/<?php echo $eid; ?>/attending', 'post', {}, function(r){ $('#fb-log').append('<p>RSVP '+(true==r ? 'succeeded' : 'failed')+'</p>'); } ); } ); | |
| </script> | |
| <a target="_new" href="http://www.facebook.com/event.php?eid=<?php echo $eid; ?>">see the <?php echo strtolower($PRIVACY); ?> event (<?php echo $eid; ?>)</a> | |
| <div id="fb-log"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment