I use another way to access facebook email in asp.net and I get user email.
my code:
script :
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
document.getElementById('MainContent_emaillbl').innerHTML = 'Please log into this app.';
} else { document.getElementById('MainContent_emaillbl').innerHTML = 'Please log into Facebook.'; }
}
function checkLoginState() {
FB.getLoginStatus(function (response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function () {
FB.init({
appId: '....',
cookie: true,
xfbml: true,
version: 'v2.2'
});
FB.getLoginStatus(function (response) {
statusChangeCallback(response);
});
};
(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'));
function testAPI() {
FB.api('/me?fields=email', function (response) {
document.getElementById('MainContent_emaillbl').innerHTML = 'Thanks for logging in, ' + response.email + '!';
});
}
</script>
html :
<asp:LinkButton ID="f_containerBTN" runat="server" CssClass="icon-container" OnClientClick="checkLoginState();"><i class="icon fa fa-facebook"></i></asp:LinkButton>
<asp:Label ID="emaillbl" runat="server" Text="Label"></asp:Label>