Cannot open My application,
I am a newbie to Facebook Application Development
I simply want to fetch user name of logged user and display it
but i cannot login and i always get error messages
this is the simple code copied for developer.facebook.com
I also tried specifying permission and redirect url, but still its of no use
PLEASE HELP OUT, i have been stuck for past two days
here is the code for PHP page
<?
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('src/facebook.php');
config = array(
'appId' => '***',
'secret' => '***',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?
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');
echo "Name: " . $user_profile['name'];
} 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.
$standalone_url = 'http://localhost/trial/';
$login_url = $facebook->getLoginUrl(array(
'next' => $standalone_url.'next.php',
'redirect_uri' => $standalone_url.'message.php',
'scope' => 'user_about_me'));
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>';
}
?>
</body>
</html>
i have tried/ already
a) Cleared all Web cache n history(web Browser: Firefox)
b) also deleted java applets and application CACHE
Please See the image in URL
to get more clear picture
In image you share your redirect uri is:
http://localhost/trial/index.phpwhich does not match your canvas uri in your configuration panel:
https://developers.facebook.com/appsSo solution is: your redirect must exactly match with
canvas urleven trailing slash:http://my_app.com/