Facebook oauth retrieve user Email

You need get email explicitly as follows:

                    var url="/me?fields=name,email";
                    FB.api(url, function (response) {
                        alert(response.name);
                        alert(response.email);
                    });

And to get the email address, email permission is needed. So the code might look like (there are other options like Register button, login button..)

            FB.login(function (response) {
                if (response.session) {
                    var url="/me?fields=name,email";
                    FB.api(url, function (response) {
                        alert(response.name);
                        alert(response.email);
                    });
                }
                else {
                    alert("User did not login successfully");
                }
            }, { scope: 'email' }); /* perms changed to scope */

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)