Login with Facebook permissions

I want to do login from Facebook to your website, I found the code, I added a params, and the code only displays the name[name] and id [id] what to do in order to display the code even for example address, age, or sex?
Below is the code.

// uses the PHP SDK. Download from https://github.com/facebook/php-sdk

// from the facebook app page
define('YOUR_APP_ID', '979304782099861');
define('YOUR_APP_SECRET', 'a1ace163e451d0fdaa0f87d8d2254030');

// new facebook object to interact with facebook
$facebook = new Facebook(array(
 'appId' => YOUR_APP_ID,
 'secret' => YOUR_APP_SECRET,
// if user is logged in on facebook and already gave permissions
// to your app, get his data:
$userId = $facebook->getUser();

 <!---<style>body { text-align:center; font-size: 40px }</style>-->
if ($userId) {
 // already logged? show some data
 $userInfo = $facebook->api('/'.$userId);
 // $facebook = json_decode($facebook, false);
 echo '<pre>';
 echo '</pre>';
echo "<p>YOU ARE: <strong>". $userInfo['name'] ."</strong><br/>";
echo '<img src="https://graph.facebook.com/'.$userInfo['id'].'/picture"></p>';

} else {
 // use javaascript api to open dialogue and perform
 // the facebook connect process by inserting the fb:login-button
 <div id="fb-root"></div>
 <fb:login-button scope='public_profile'></fb:login-button>
 window.fbAsyncInit = function() {
 appId : <?=YOUR_APP_ID?>,
 status : true,
 cookie : true,
 xfbml : true,
 oauth : true,

FB.Event.subscribe('auth.login', function(response) {
 // ------------------------------------------------------
 // This is the callback if everything is ok

 var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";

Thank you in advance

Source: facebook

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.