My index.php:
<?php
//uses the PHP SDK. Download from https://github.com/facebook/php-sdk
//require 'facebook-platform/php/facebook.php';
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => '289329761120769',
'secret' => '9cad1979d8379605dc04e3c48bf7c18c'
));
$userId = $facebook->getUser();
?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<?php if ($userId) {
$userInfo = $facebook->api('/' + $userId); ?>
Welcome <?= $userInfo['name'] ?> </br>
gender <?= $userInfo['gender'] ?> </br>
username <?= $userInfo['username'] ?> </br>
email <?= $userInfo['email'] ?> </br>
website <?= $userInfo['website'] ?> </br>
<img src="https://graph.facebook.com/<?= $userInfo['id'] ?>/picture"/> </br>
<?php } else { ?>
<div id="fb-root"></div>
<div class="fb-login-button" scope="email,user_website">
Login with Facebook
</div>
<!--fb:login-button" data-scope="email,user_website"></fb:login-button-->
<?php } ?>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '289329761120769',
status : true,
cookie : true,
xfbml : true,
oauth : true
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
};
(function(d){
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";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
</body>
</html>