[英]How can I get Facebook user information by access token?
我使用Angular 2 Cordova Oauth插件[ https://github.com/nraboy/ng2-cordova-oauth]在我的Cordova應用中實現FB登錄。
然后,我成功獲取用戶訪問令牌。 這是我的代碼。
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);
});
但是我不知道在獲取Facebook訪問令牌后如何檢索用戶詳細信息的方法,因為我沒有在此應用中使用Facebook SDK。 如果有人知道解決方案,請回答我。
您需要使用收到的訪問令牌向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=>{});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.