简体   繁体   中英

How can I get Facebook user information by access token?

I use Angular 2 Cordova Oauth plugin [ https://github.com/nraboy/ng2-cordova-oauth] to implement FB login in my Cordova app.

Then I succeeded fetching user access token. Here is my code.

this.oauth.logInVia(this.facebookProvider).then(success => {
  console.log("RESULT: " + JSON.stringify(success));
  // HERE I WANT TO SEND REQUEST TO GET USER INFORMATION
}, error => {
  console.log("ERROR: ", error);
});

But I don't know the way to retrieve user details after getting Facebook access token because I don't use Facebook SDK in this app. If anyone know a solution, please answer me it.

您需要使用收到的访问令牌向Facebook Graph API发出GET请求。

 this.http.get(`https://graph.facebook.com/me?fields= "name,gender,location,picture/*any other fields*/&access_token=${access_token}`, new RequestOptions('Headers':new Headers({'Content-type:application/json'}))).then(result=>{});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM