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

FBSDKGraphRequest in React Native returning incomplete object

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

{ "id": "162036280799349", "birthday": "08/08/1980", "email": "test_ppjeffg_eight\u0040tfbnw.net", "first_name": "Test", "gender": "male", "last_name": "Eight", "link": "https://www.facebook.com/app_scoped_user_id/162036280799349/", "locale": "en_US", "name": "Test Eight", "timezone": -8, "updated_time": "2015-07-28T18:22:16+0000", "verified": false }

我刚刚得到

Object {name: "Test Eight", 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');

但是,您在 return 中获得哪些字段取决于您的应用程序的权限和用户的设置。

此外,请注意 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 中工作。