HTML:
Basically, once the login is done, it will call the callLoginMethod () method that will display the information.
<div class="fb-login-button" data-scope="email,user_birthday,user_hometown,user_location,user_location" data-max-rows="1" data-size="medium" data-show-faces="false" data-auto-logout-link="false" onlogin="callLoginMethod();" login_text="Entrar com o Facebook"> </div>
Javascript:
window.fbAsyncInit = function() {
FB.init({
appId : SEU_APP_ID,
xfbml : true,
version : 'v2.8'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function basicAPIRequest() {
FB.api('/me',
{fields: "id,picture,birthday,email,first_name,gender,name,location,hometown"},
function(response) {
console.log('Resposta:', response);
}
);
}
function callLoginMethod() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
basicAPIRequest();
} else {
FB.login();
}
});
}