Facebook API - different user ID's for each app?

我们两清 提交于 2019-12-05 05:08:07

Well, this is very old news. It's been like that since April 30th 2014. With the introduction of the graph API v2.0, FB also introduced the Business Mapping API, which is designed for your use case.

You won't receive one user id, but you'll receive a token_for_business:

This returns a string which is the same for this person across all the apps managed by the same Business Manager.

See

LoginManager.logInWithReadPermissions(['email']).then((result) => {
          if (result.isCancelled){
            //console.warn("Login is canceled");
          } else {
             AccessToken.getCurrentAccessToken().then((data) =>{
             const responseInfoCallback = (error, result) => {
                if (error) {

                } else {
                    //you can pick data.userID  and data.applicationID
                    //To getting unique id of user by application
                    //I think you can use (data.userId + data.applicationId) as the id
                    //For getting profile you can use result.name, result.id (it likes data.userId)
                    //Token is available in data.accessToken

                }
              }
              const infoRequest = new GraphRequest(
                '/me',
                {
                  accessToken: data.accessToken,
                  parameters: {
                    fields: {
                      string: 'email, name, gender, picture,cover, id'
                    }
                  }
                },
                responseInfoCallback
              );
              new GraphRequestManager().addRequest(infoRequest).start()
        })
          }
        }, (error) => {
          console.warn(error)
        });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!