Facebook API get email address -
i have make website login facebook. makes sense able send them email, can't email address facebook.
i followed instructions https://developers.facebook.com/docs/facebook-login/getting-started-web/ add {scope:email} in fb.login.
how can email address facebook api?
my code now:
<div id="fb-root"></div> <script> window.fbasyncinit = function() { fb.init({ appid : 'app', // app id channelurl : '//domain.com/channel.php', // channel file status : true, // check login status cookie : true, // enable cookies allow server access session xfbml : true // parse xfbml }); fb.event.subscribe('auth.authresponsechange', function(response) { if (response.status === 'connected') { fb.api('/me', function(response) { console.log(response); }); } else if (response.status === 'not_authorized') { fb.login(function(response) {},{scope: 'email'}); } else { fb.login(function(response) {}, {scope: 'email'}); } }); }; // load sdk asynchronously (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)); </script> <fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>
i ran same issue. deauthorize app fb account. authorize app again through test page
i found didn't hit below block once authorized app first time. (adding scope:email fb.login once app has been authorized no good... think)
} else if (response.status === 'not_authorized') { fb.login(function(response) {},{scope: 'email'}); } else { fb.login(function(response) {}, {scope: 'email'}); }
hope helps
Comments
Post a Comment