I am trying to get user id, name, email. Getting id and name but not email. I have this code:
<html>
<head></head>
body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxx',
status : true,
cookie : true,
xfbml : true
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
FB.login();
} else {
FB.login();
}
});
};
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function testAPI() {
FB.api('/me', function(response) {
console.log(response.name + '---'+response.email);
});
}
</script>
<fb:login-button show-faces="true" width="200" max-rows="1" scope="public_profile,email"></fb:login-button>
</body>
</html>
Output is:
FirstName LastName---undefined
Why email is undefined? I also want to get all informations possible to get. How?