Skip to content

Instantly share code, notes, and snippets.

@jc1arke
Created August 6, 2010 06:29
Show Gist options
  • Save jc1arke/510934 to your computer and use it in GitHub Desktop.
Save jc1arke/510934 to your computer and use it in GitHub Desktop.
<?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