最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I get Facebook user information by access token? - Stack Overflow

programmeradmin4浏览0评论

I use Angular 2 Cordova Oauth plugin [] 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.

I use Angular 2 Cordova Oauth plugin [https://github./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.

Share Improve this question asked Jan 7, 2017 at 7:18 taku845taku845 1331 gold badge3 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You need to make a GET request to Facebook Graph API with the access token received.

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

评论列表(0)

  1. 暂无评论