Wizcorp / phonegap-facebook-plugin

The official plugin for Facebook in Apache Cordova/PhoneGap
Other
1.91k stars 2k forks source link

Facebook email is returned from api call as undefined #1335

Open sarahmonks opened 7 years ago

sarahmonks commented 7 years ago

I am using the facebookConnect api call to get a user's public profile information however the email address is coming back undefined. Is there something else i should add into the following code?

facebookConnectPlugin.api('/me?fields=id, email, link, name, picture', ["public_profile"],function(data){
        var fb_user_id = data.id;
        var fb_email = data.email;
        var fb_name = data.name;
        var fb_picture_url = data.picture.data.url;
        var fb_user_link = data.link;
    alert("fb_email" + fb_email);
}); //end api call

thanks

Slavezax commented 7 years ago

+1

rodrigobsmunifeob commented 7 years ago

+1

mervantanrikulu commented 7 years ago

sorry im english beginner :( but i write this code i share you...

   var fbLoginSuccess = function (userData) {
        facebookConnectPlugin.api("me/?fields=first_name,gender", ["public_profile"],
            function (result) {
                cinsiyet = result['gender'];
                localStorage.setItem("cinsiyet", cinsiyet);
                isim = result['first_name'];
                localStorage.setItem("isim", isim);
            },
            function (error) {
            alert("Failed: " + error);
            });

        faceid = JSON.stringify(userData['authResponse']['userID']);

        baslat();
    }

    facebookConnectPlugin.login(["public_profile"],
        fbLoginSuccess,
        function (error) {
            if (interval != null) { clearInterval(interval); } var interval = setInterval(facekontrol(), 5000);  document.getElementById("ortaAlan").innerHTML = "<img src ='images/facebookloginerror.png' name='facekontrol' onclick='facekontrol()'   id='facekontrol' style='width:100%; height:auto; margin-top: 40%; margin - left:auto; margin - right:auto; '/>";
        }
    );

good work :)

jensbroecher commented 6 years ago

Same issue, id and name works, email stopped working