Display The Name and the Photo of the current User of your Api ...
try.php Code
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 | |
// Remember to copy files from the SDK's src/ directory to a | |
// directory in your application on the server, such as php-sdk/ | |
require 'config.php'; | |
$user_id = $facebook->getUser(); | |
if($user_id) { | |
// We have a user ID, so probably a logged in user. | |
// If not, we'll get an exception, which we handle below. | |
try { | |
$user_profile = $facebook->api('/me','GET'); | |
$user = $facebook->getUser(); | |
?> | |
<p><b><span class="style3">Welcome</span> : <a href="http://www.facebook.com/ | |
<?php echo $user; ?> " target="_parent"> <?php echo $user_profile['name']; ?> </a></b></p> | |
<p><img src="https://graph.facebook.com/<?php echo $user; ?>/picture"> | |
<?php | |
} catch(FacebookApiException $e) { | |
// If the user is logged out, you can have a | |
// user ID even though the access token is invalid. | |
// In this case, we'll get an exception, so we'll | |
// just ask the user to login again here. | |
$login_url = $facebook->getLoginUrl(); | |
echo 'Please <a href="' . $login_url . '">login.</a>'; | |
error_log($e->getType()); | |
error_log($e->getMessage()); | |
} | |
} else { | |
// No user, print a link for the user to login | |
$login_url = $facebook->getLoginUrl(); | |
echo 'Please <a href="' . $login_url . '">login.</a>'; | |
} | |
$redirectUrlk = "https://www.facebook.com/dialog/oauth?client_id=118487369116&redirect_uri=http://evry1falls.freevar.com/test12/index.php&state | |
=5da7ce9f0201f209c7d699cb881c3b02&scope=read_stream,friends_likes"; ?> | |
</p> | |
<p align="center"><a href = "<? $redirectUrlk ; ?> . "><strong>Back</strong></a> |