Created
August 6, 2010 06:29
-
-
Save jc1arke/510934 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$fbconfig['appid'] = "your-application-id-here"; | |
$fbconfig['api'] = "your-application-api-key"; | |
$fbconfig['secret'] = "your-application-secrey-key"; | |
try | |
{ | |
include_once "facebook.php"; | |
} | |
catch( Exception $e ) | |
{ | |
d( $e ); | |
} | |
// Create our application instance | |
$facebook = new Facebook( array( 'appId' => $fbconfig['appid'], 'secret' => $fbconfig['secret'], 'cookie' => true ) ); | |
// We may or may not have this data based on a $_GET or $_COOKIE based session. | |
// If we get a session here, it means we found a correctly signed session using | |
// the application secret only Facebook and the application knows. We don't know | |
// if it is still valid until we make an API call using the session. A session | |
// can become invalid if it has already expired (should not be getting the session | |
// back in this scenario) or if the user logged out of FaceBook. | |
$session = $facebook -> getSession(); | |
$fbMe = null; | |
// Session based Graph API Call | |
if( $session ) : | |
try | |
{ | |
$uid = $facebook -> getUser(); | |
$fbMe = $facebook -> api( '/me/' ); | |
} | |
catch( FacebookApiException $e ) | |
{ | |
d( $e ); | |
} | |
endif; | |
function d( $error ) | |
{ | |
echo "<pre>" . print_r( $error ) . "</pre>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment