cordova facebook登录FB.api呼叫不工作 [英] cordova facebook login FB.api call not working
本文介绍了cordova facebook登录FB.api呼叫不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用cordova facebook登录,使用 phonegap-facebook-plugin ,
I am working on cordova facebook login, with the phonegap-facebook-plugin,
在使用 FB.getLoginStatus
I am using the following function after checking the login status of the user with FB.getLoginStatus
function processFacebook(token) {
FB.api('/me', 'get', {
access_token: token
}, function(response) {
alert(response);
});
}
但是,我无法收到任何回复。
任何人可以指出我出错的地方吗?
我从这个,但方法似乎不起作用。
以下是原始的链接index.js 和 index.html 文件
but, I am unable to receive any response. Can anybody point out where I am going wrong? I took the reference from this , but the method seems not to work. Here's the link to the original index.js and index.html file
推荐答案
尝试这些东西。
获取访问令牌
var fbLoginSuccess = function (userData) {
alert("UserInfo: ", userData);
facebookConnectPlugin.getAccessToken(function(token) {
alert("Token: " + token);
});
}
获取用户个人资料数据。
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))
});
}
它会给你所有相关的用户详细信息个人资料。
这篇关于cordova facebook登录FB.api呼叫不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文