gpt4 book ai didi

ios - React Native 中的 FBSDKGraphRequest 返回不完整的对象

转载 作者:行者123 更新时间:2023-11-29 10:22:48 25 4
gpt4 key购买 nike

所以我已经实现了 react native FBSDKGraphRequest 和登录按钮。登录工作正常,但是当我尝试用户的图形请求时,我希望/me 端点返回完整的对象,而不是完整的对象

{
“编号”:“162036280799349”,
“生日”:“1980 年 8 月 8 日”,
“电子邮件”:“test_ppjeffg_eight\u0040tfbnw.net”,
"first_name": "测试",
“性别”:“男”,
"last_name": "八",
“链接”:“https://www.facebook.com/app_scoped_user_id/162036280799349/”,
“语言环境”:“en_US”,
"name": "测试八",
“时区”:-8,
“更新时间”:“2015-07-28T18:22:16+0000”,
“已验证”:假

我刚刚明白

对象{名称:“测试八”,id:“162036280799349”}

虽然我已根据文档完成所有操作,但我很可能没有正确执行请求。相关源码如下:

class LoadingOverlay extends BaseComponent{
constructor(props){
super(props);
this._bind(/*'_fetchFriendsRequestFunction'*/);
this.state = {isVisible: true,
token: null,
profileInfo: null}


}

_fetchGraphRequestFunction(){
console.log("start");
var fetchProfileRequest = new FBSDKGraphRequest((error, result) => {
if (error) {
alert('Error making request.');
} else {
// Data from request is in result
console.log(result);
}
}, '/me');
// Start the graph request.
fetchProfileRequest.start();

}

render(){
return(
<Overlay isVisible={this.state.isVisible}>
<BlurView style={styles.background} blurType="dark">
<FBSDKLoginButton
onLoginFinished={(error,result)=>{
if (error){
alert('Error Logging In.');
} else {
if (result.isCanceled){
alert('Login Cancelled.');
} else {
FBSDKAccessToken.getCurrentAccessToken((token)=>{
console.log(token.tokenString);
this._fetchGraphRequestFunction();
})


}
}
}}
onLogoutFinished={()=>console.log('Logged Out.')}
readPermissions={['public_profile', 'email', 'user_birthday', 'user_friends']}
publishPermissions={['publish_actions']}/>
</BlurView>

</Overlay>
);
}
}`

最佳答案

您可以通过将它们附加到 uri 来从 Facebook 请求其他参数:

/me?fields=id,name,email

或者像这样在 FBSDKGraphRequest 对象上调用 addStringParameter 函数:

fetchProfileRequest.addStringParameter('picture,email,gender','fields');

但是,您返回的字段取决于您的应用程序的权限和用户的设置。

此外,请注意 ios FB sdk 文档中的这个小技巧:https://developers.facebook.com/docs/reference/ios/current/class/FBSDKLoginButton/

Note, that if read permissions are specified, then publish permissions should not be specified.

因此尝试发送一个空的 publishPermissions 参数,看看是否修复了它。

更多信息在这里: Publish or manage permissions are not permited to to be requested with read permissions FACEBOOK SDK

https://coderwall.com/p/gkeqcq/request-read-and-publish-permissions-simultaneously-using-ios-facebook-support

如果有人有的话,我很乐意看到一个流程示例,使它在 React Native 中工作。

关于ios - React Native 中的 FBSDKGraphRequest 返回不完整的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34030082/

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