-1

I am using FB SDK v2.8. What I tried doesn't show user's email. It doesn't matter if I log in with my mobile phone, or email address. How can I get the user's email?

In my fb app dashboard, I can see email permission in approved items section

<div class="fb-login-button" data-max-rows="1" data-size="large"
    data-show-faces="false" data-auto-logout-link="true"></div>

(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'));

window.fbAsyncInit = function() {
    FB.init({
        appId : 'app_id',
        cookie : true,
        xfbml : true,
        version : 'v2.8'
    });
    FB.AppEvents.logPageView();

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
     .... 
  } else if(response.status === 'not_authorized'( {
     .... }
    else {
     ... }
});
function getCurrentUserInfo() {
        FB.api("/me", {
            locale : 'en_US',
            fields : 'name, email, gender, birthday, currency, website'
        }, function(response) {
            console.log(response);
            console.log(response.name + ': ' + response.email);
        }
    });

approved_items enter image description here

  • It's weird to see a downvote with no explanation.
Eniss
  • 975
  • 2
  • 20
  • 40

1 Answers1

1

You are asking only for the default public_profile permission, you have to ask the email permission also.

Check the documentation here

FB.login(function(response) {
   console.log(response);
}, {scope: 'email'});
todes
  • 346
  • 1
  • 6