Código:
<?php
require_once 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxx',
'cookie' => true
));
$session = $facebook->getSession();
$me = null;
if(!empty($session)) {
try {
$uid = $facebook->getUser();
$user = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
}
print_r($uid);
if(!empty($user)){
print_r($user);
} else {
print "There was an error";
}
} else {
$params = array (
'fbconnect' => 0,
'canvas' => 1,
//'next' => 'http://apps.facebook.com/aerolineass',
'req_perms' => 'email', 'me'
);
$URL = $facebook->getLoginUrl($params);
echo "<fb:redirect url=\"$URL\">";
}
?>
<h3>You</h3>
<img src="https://graph.facebook.com/<?php echo $uid; ?>/picture">