<div class="fb-login-button" data-max-rows="1" data-size="xlarge" data-show-faces="true" data-auto-logout-link="false"
data-scope="public_profile,email,user_friends" onlogin="checkLoginState()";>
</div>
<script>
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
loggedIn();
} else if (response.status === 'not_authorized') {
//User is logged into FB, but not my app
} else {
//User is not logged into FB
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
function loggedIn(){
FB.api('/me'),(function(response){
console.log(JSON.stringify(response));
});
}
window.fbAsyncInit = function() {
FB.init({
appId : <MY APP ID>,
cookie : true,
xfbml : true,
version : 'v2.5'
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
(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'));
</script>
For security purpose , not given my app id. This works fine and am able to retrieve user name. But I would like to retrieve the mail id .API call to /me does not retrieve the mail address. Please someone help me out if I am missing out some thing. Thanks in advance