(对于它的价值;我有这个工作,但为了兼容iOS,我不得不切换插件)
希望这是我最后一次询问这个问题。我现在使用以下plugin进行 phonegap build :
<gap:plugin name="cordova-plugin-facebook4" source="npm">
对于它的重要性,在此版本的CLI上:
<preference name="phonegap-version" value="cli-5.2.0" />
我的登录工作正常,但它没有运行api
函数的回调:
var fbLoginSuccess = function (response) {
alert ("success");
storage.setItem("user_auth",response.authResponse.accessToken); //get access token
user_auth = response.authResponse.accessToken;
login_data.auth_token = response.authResponse.accessToken; //get access token
login_data.account_id = response.authResponse.userID; //get facebookConnectPlugin UID
login_data.expires = response.authResponse.expiresIn; //get expire duration
login_data.socialmedia_name = 'facebook';
facebookConnectPlugin.api("/v2.3/me/?fields=id,email,first_name,last_name",["public_profile","email"], function(profileData) {
alert ("api success");
login_data.email = profileData.email;
login_data.display_name = profileData.first_name + " " + profileData.last_name;
//...
});
}
var fb_login = function() {
var login_data = {};
client.cmd = "login";
login_data.userid = user_id;
login_data.cmd = "login";
facebookConnectPlugin.login([
'public_profile',
'email',
'user_posts',
'user_photos',
'user_videos',
'user_friends'
], fbLoginSuccess,
function (error) {
console.error(error);
}
);
}
我已按照this link的指示进行了另一次尝试:
var fbLoginSuccess = function (response) {
storage.setItem("user_auth",response.authResponse.accessToken); //get access token
user_auth = response.authResponse.accessToken;
login_data.auth_token = response.authResponse.accessToken; //get access token
login_data.account_id = response.authResponse.userID; //get facebookConnectPlugin UID
login_data.expires = response.authResponse.expiresIn; //get expire duration
login_data.socialmedia_name = 'facebook';
facebookConnectPlugin.api("/me",null,function(profileData) {
alert ("api success");
login_data.email = profileData.email;
login_data.display_name = profileData.first_name + " " + profileData.last_name;
//...
});
}
但没有运气 - 我肯定错过了一些非常简单的东西 - 它是什么?