Cordova Facebook Login Fb.api Call Not Working
I am working on cordova facebook login, with the phonegap-facebook-plugin, I am using the following function after checking the login status of the user with FB.getLoginStatus func
Solution 1:
Try this stuff.
To get Access Token.
var fbLoginSuccess = function (userData) {
alert("UserInfo: ", userData);
facebookConnectPlugin.getAccessToken(function(token) {
alert("Token: " + token);
});
}
Get user Profile data.
var fbLogin = function() {
facebookConnectPlugin.login(["public_profile", "email", "user_birthday", "user_location"],
function(response) {
console.log("Login Response :" + JSON.stringify(response));
//alert("Login Response :" + JSON.stringify(response))this.authId = response.authResponse.userID;
if (response.status == "connected") {
facebookConnectPlugin.api("/" + response.authResponse.userID, ["public_profile", "email", "user_birthday", "user_location"],
function(result) {
this.email = result.email;
this.firstname = result.first_name;
this.lastname = result.last_name;
this.birthdate = result.birthday;
this.city = result.location.name;
},
function(error) {
alert("Failed: " + error);
});
}
},
function(response) {
alert("Other Response : " + JSON.stringify(response))
});
}
It will give you all the Relevant details of User Profile.
Solution 2:
try this code
var fbLoginSuccess = function (userData) {
alert("UserInfo: " + JSON.stringify(userData));
facebookConnectPlugin.getAccessToken(function(token) {
alert("Token: " + token);
}, function(err) {
alert("Could not get access token: " + err);
});
}
Post a Comment for "Cordova Facebook Login Fb.api Call Not Working"