gpt4 book ai didi

cordova - 如何在 ngcordova facebook 登录回调对象中获取电子邮件 ID

转载 作者:行者123 更新时间:2023-12-03 03:11:28 26 4
gpt4 key购买 nike

我已经安装了 cordova inapp 浏览器插件来添加社交 Facebook 登录。问题是,在我的应用程序中,我只允许通过 Facebook 登录,而不允许注册。在我的网络应用程序上,如果该用户已注册,则只有他/她可以访问移动应用程序。因此,要从移动应用程序登录,回调后是否可以接收用户在 Facebook 按钮单击打开的应用程序内浏览器中提供的电子邮件 ID?如果我收到电子邮件 ID,我可以交叉验证他/她在数据库中的存在吗?可以这样做吗?

我的代码是这样的:

    $scope.getDeviceInfo = function() {
$cordovaOauth.facebook("777846192309223", ["email"]).then(function(result) {
alert('success login:'+JSON.stringify(result));
}, function(error) {
alert('error: '+error);
});
}

上面参数中的email是我想在成功登录后从facebook获取的用户数据。但我得到的 access_token 大约为 50 位数字,另一个参数 expires_in 的时间戳为 7 位数字。我在这里收不到电子邮件。如何得到它?

最佳答案

$scope.getDeviceInfo = function() {
$cordovaOauth.facebook("777846192309223", ["email"]).then(function(result) {
alert('success login:'+JSON.stringify(result));
$localStorage.accessToken = result.access_token;
if($localStorage.hasOwnProperty("accessToken") === true) {
$http.get("https://graph.facebook.com/v2.2/me", { params: { access_token: $localStorage.accessToken, fields: "id,name,gender,location,website,picture,relationship_status",email format: "json" }}).then(function(result) {
$scope.profileData = result.data;
}, function(error) {
alert("There was a problem getting your profile. Check the logs for details.");
console.log(error);
});
} else {
alert("Not signed in");
$location.path("/login");
}
}, function(error) {
alert('error: '+error);
});
}

将访问 token 存储到本地存储。并使用 facebook graph api 获取用户电子邮件 ID 等

关于cordova - 如何在 ngcordova facebook 登录回调对象中获取电子邮件 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30843369/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com