gpt4 book ai didi

android - 在 native react 中没有从 fbsdk 获取电子邮件 ID

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:05:33 26 4
gpt4 key购买 nike

我正在获取登录成功和 accessToken 。我做的

我试过了

LoginManager.logInWithReadPermissions([
'email',
'public_profile',
'user_likes',
])

然后这个

LoginManager.logInWithPublishPermissions([
'publish_actions',
]).then((result) => {
if (result.isCancelled) {
console.log('Login cancelled');
} else {
AccessToken.getCurrentAccessToken().then((data) => {
const accessToken = data.accessToken;
const responseInfoCallback = (error, result) => {
if (error) {
console.log(error);
console.log('Error fetching data=', error.toString());
} else {
console.log('Success fetching data=', result.toString());
}
};
const infoRequest = new GraphRequest(
'/me',
{
accessToken,
parameters: {
fields: {
string: 'email,name,first_name,middle_name,last_name',
},
},
},
responseInfoCallback,
);
new GraphRequestManager().addRequest(infoRequest).start();
});
}
});

'权限登录成功', 'email,public_profile'用户个人资料数据是

{ first_name: 'XXXXXX',
name: 'XXXXXX YYYYY',
last_name: 'YYYYYY',
id: '1319989423636921696328130092' }

但没有获取用户电子邮件 ID,这里有什么问题。如何在应用程序中登录 Facebook 后获取电子邮件 ID。

最佳答案

这就是我在我的项目中所做的并成功检索电子邮件的方式

LoginManager.logInWithReadPermissions(['public_profile', 'email', 'user_friends']).then(
(result) => {
if (result.isCancelled) {
console.log('Login cancelled')
} else {
AccessToken.getCurrentAccessToken().then(
(data) => {
this._fbHome();// Navigatin to next screen
}
)
}
},
(error) => {
console.log('Login fail with error: ' + error)
}
)

然后在导航到下一个屏幕后我正在提取用户数据

const infoRequest = new GraphRequest(
'/me?fields=name,email,picture.type(large)',
null,
this._responseInfoCallback
);
new GraphRequestManager().addRequest(infoRequest).start();


_responseInfoCallback = (error, result) => {
if (error) {
alert('Error fetching data: ' + error.toString());
} else {
this.setState({ userName: result.name, userEmail: result.email ,userPic:result.picture.data.url});
AsyncStorage.setItem("UserName",this.state.userName);
AsyncStorage.setItem("Email", this.state.userEmail);
AsyncStorage.setItem("UserPic", this.state.userPic);

// SharedPreferences.setItem("UserName", this.state.userName);
// SharedPreferences.setItem("Email", this.state.userEmail);
// SharedPreferences.setItem("UserPic", this.state.userPic);
console.log("Picture"+ this.state.userPic + "Name" + this.state.userName + "Email" + this.state.userEmail);
}
}

关于android - 在 native react 中没有从 fbsdk 获取电子邮件 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46057608/

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