I have a website with the Facebook login implementation. My app has the permission for the user\'s email. Even though the user logs into my app using Facebook I can only ret
There is problem in email. If the user email is not verified then it will show an undefined, If the email is well verified then it will show the logged in email. Please try to login and try to print the name, I have solved my problem in this way.. Check this link which is mentioned by Hugo. Its really helpful. https://developers.facebook.com/bugs/298946933534016/
you probably don't have email permission even though you think you do.
Try,
FB.login(function(){
FB.api('me',
function(response){
console.log(response.email);
});
},{'scope':'email'});
You now have to specify the fields you want to get, it´s called "Declarative Fields":
FB.api('/me', {fields: 'name,email'}, function(response) {
console.log('Good to see you, ' + response.email + '.');
});
See the changelog for more information: https://developers.facebook.com/docs/apps/changelog#v2_4
If the problem persists in the particular email account. Solution is: you have to ask the people to login with their facebook email id The issue with me was undefined email when i connect with my personal account Then tried lot of the things finally logged in with my facebook email id .It worked
The facebook account which has the username defined that makes the problem to log into your app
The user probably had a non-verified email on Facebook. What you could do is to ask them to verify their email on the Facebook settings (Facebook will send them an email with a link to click on) and try again.
<html>
<head></head>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxx',
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?fields=name,email', 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>
ref:Getting user email undefined using facebook api