Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to use facebook JS SDK correctly
    text
    copied!<p>I am using facebook JS SDK for user login. I am confused on how it is working. When I am using this code:</p> <pre><code>FB.init({ appId : '*********************************', channelURL: '*********************************', cookie : true, xfbml : true, oauth : true }); FB.getLoginStatus(function(response){ if(response.status == 'connected') { } else if(response.status == 'not_authorized') { /* Not Authorized */ login(); } else { /* Not Logged In*/ /*login();*/ } }); FB.Event.subscribe('auth.login', function(response) { window.location.reload(); }); FB.Event.subscribe('auth.logout', function(response) { window.location.reload(); }); }; /* method window.fbAsyncInit ends here*/ /* Checks user login status on facebook*/ function login(){ FB.login(function(response) { if (response.authResponse) { //connected } else { //cancelled } }, {scope: 'email'}); } /*function login ends here*/ </code></pre> <p>I am not able to get the user email id.</p> <p>While if i am using this one it is giving me user email id.</p> <pre><code>FB.init({ appId : '********************', channelURL: '********************', cookie : true, xfbml : true, oauth : true }); FB.getLoginStatus(function(response){ if(response.status == 'connected') { /* Connected Successfully */ FB.login(function(response) { // handle the response if (response.authResponse) { } else { //cancelled } }, {scope: 'email,user_likes'}); } else if(response.status == 'not_authorized') { /* Not Authorized */ login(); } else { /* Not Logged In*/ /*login();*/ } }); FB.Event.subscribe('auth.login', function(response) { window.location.reload(); }); FB.Event.subscribe('auth.logout', function(response) { window.location.reload(); }); }; /* method window.fbAsyncInit ends here*/ /* Checks user login status on facebook*/ function login(){ FB.login(function(response) { if (response.authResponse) { //connected } else { //cancelled } }, {scope: 'email,user_likes'}); } /*function login ends here*/ </code></pre> <p>I am getting the email id. </p> <p>Please point me where I am doing wrong in the first code ?</p> <p>Edited: As per suggestion I have added the {scope: 'email,user_likes'} in the login function but still not working.</p> <p>Thanks </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload