Facebook php SDK problem

by 1 replies
2
Hey warriors,
I am new to facebook-login system. I have put the following code in http://beta.jokesnfunnypics.com/login . I am writing '$' as DOLLAR as warriorforum is screwing it up when displayed:-
Code:
<?php

require 'src/facebook.php';

dollarfacebook = new Facebook(array(
  'appId'  => 'xx',
  'secret' => 'xx',
));

// Get User ID
dollaruser = dollarfacebook->getUser();

if (dollaruser) {
  try {
    dollaruser_profile = dollarfacebook->api('/me');
  } catch (FacebookApiException dollare) {
    error_log(dollare);
    dollaruser = null;
  }
}

if (dollaruser) {
  dollarlogoutUrl = dollarfacebook->getLogoutUrl();
} else {
  dollarloginUrl = dollarfacebook->getLoginUrl();
}


?>

<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>php-sdk</title>
    <style>
      body {
        font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
      }
      h1 a {
        text-decoration: none;
        color: #3b5998;
      }
      h1 a:hover {
        text-decoration: underline;
      }
    </style>
  </head>
  <body>
    <h1>php-sdk</h1>

    <?php if (dollaruser): ?>
      <a href="<?php echo dollarlogoutUrl; ?>">Logout</a>
    <?php else: ?>
      <div>
        Login using OAuth 2.0 handled by the PHP SDK:
        <a href="<?php echo dollarloginUrl; ?>">Login with Facebook</a>
      </div>
    <?php endif ?>

    <h3>PHP Session</h3>

    <?php if (dollaruser): ?>
      <h3>You</h3>
      <img src="https://graph.facebook.com/<?php echo dollaruser; ?>/picture">
      <?php echo dollaruser_profile[name]; ?>
    <?php else: ?>
      <strong><em>You are not Connected.</em></strong>
    <?php endif ?>


  </body>
</html>
But after getting the permission, no info is displayed in the page. Please help me. Thanks in advance.
#programming #facebook #php #problem #sdk
  • Banned
    Are these set?

    'appId' => 'xx',
    'secret' => 'xx',

Next Topics on Trending Feed

  • 2

    Hey warriors, I am new to facebook-login system. I have put the following code in http://beta.jokesnfunnypics.com/login . I am writing '$' as DOLLAR as warriorforum is screwing it up when displayed:- Code: <?php require 'src/facebook.php'; dollarfacebook = new Facebook(array( 'appId' => 'xx', 'secret' => 'xx', )); // Get User ID dollaruser = dollarfacebook->getUser(); if (dollaruser) { try { dollaruser_profile = dollarfacebook->api('/me'); } catch (FacebookApiException dollare) { error_log(dollare); dollaruser = null; } } if (dollaruser) { dollarlogoutUrl = dollarfacebook->getLogoutUrl(); } else { dollarloginUrl = dollarfacebook->getLoginUrl(); } ?> <!doctype html> <html xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title>php-sdk</title> <style> body { font-family: 'Lucida Grande', Verdana, Arial, sans-serif; } h1 a { text-decoration: none; color: #3b5998; } h1 a:hover { text-decoration: underline; } </style> </head> <body> <h1>php-sdk</h1> <?php if (dollaruser): ?> <a href="<?php echo dollarlogoutUrl; ?>">Logout</a> <?php else: ?> <div> Login using OAuth 2.0 handled by the PHP SDK: <a href="<?php echo dollarloginUrl; ?>">Login with Facebook</a> </div> <?php endif ?> <h3>PHP Session</h3> <?php if (dollaruser): ?> <h3>You</h3> <img src="https://graph.facebook.com/<?php echo dollaruser; ?>/picture"> <?php echo dollaruser_profile[name]; ?> <?php else: ?> <strong><em>You are not Connected.</em></strong> <?php endif ?> </body> </html> But after getting the permission, no info is displayed in the page. Please help me. Thanks in advance.