Search code examples
facebookcordovafacebook-graph-apifacebook-graph-api-v2.4

Facebook API v2.4 : How to get email id of FB user in cordova fb plugin


I'm using " com.phonegap.plugins.facebookconnect " Cordova plugin for FB login in my Phonegap app. My Facebook app is v2.4 . I'm getting only full name and id as login response.But I need email id of user to complete my login process on app.

But when i'm login with same fb credential in my old app i got all details of user as response.This app is connect with facebook app v2.3

Is there any way to get email id of fb user on login ?

My code :

 $cordovaFacebook.login(["public_profile", "email", "user_friends"])
                .then(function(success) {
                 //success
                }, function (error) {
                //error
               });

$cordovaFacebook.api("me", ["public_profile"])
    .then(function(success) {
    //success
} }, function (error) {
                //error
               });

Thanks in advance


Solution

  • Search for "Declarative Fields" in the changelog: https://developers.facebook.com/docs/apps/changelog#v2_4

    You now have to define the fields you want to get in the API calls. The basic call for the /me endpoint would be like this: /me?fields=name,email