Created
September 3, 2010 21:49
-
-
Save jordanandree/564624 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 | |
require 'facebook.php'; | |
function facebook_connect(){ | |
// Create our Application instance (replace this with your appId and secret). | |
$facebook = new Facebook(array( | |
'appId' => '145062682199939', | |
'secret' => '', | |
'cookie' => true, | |
)); | |
$session = $facebook->getSession(); | |
$me = null; | |
// Session based API call. | |
if ($session) { | |
try { | |
$me = $facebook->api('/me'); | |
} catch (FacebookApiException $e) { | |
error_log($e); | |
} | |
} | |
if ($me) { | |
$me['logoutUrl'] = $facebook->getLogoutUrl(); | |
$me['uid'] = $facebook->getUser(); | |
} else { | |
$me['$loginUrl'] = $facebook->getLoginUrl(); | |
} | |
// set to return so we dont echo data on every call | |
return $me; | |
} | |
$fb_data = facebook_connect(); | |
if($fb_data){ | |
echo $fb_data['name']; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment