FB.login访问令牌facebook javascript SDK

时间:2012-09-12 12:01:15

标签: javascript facebook facebook-graph-api facebook-javascript-sdk

我正在使用

 FB.login(function(response) {
   if (response.authResponse) {
     console.log('Welcome!  Fetching your information.... ');
     var access_token =   FB.getAuthResponse()['accessToken'];
     window.location = "https://graph.facebook.com/me?"+access_token;
   }
 });

将我重定向到以下结果:

{
  "error": {
  "message": "An active access token must be used to query information about the current user.",
  "type": "OAuthException",
  "code": 2500
  }
}

我在这里做错了什么?为什么我没有获得正确的访问令牌?

1 个答案:

答案 0 :(得分:1)

您应该能够使用response.authResponse.accessToken

此外,您需要将access_token变量附加到Graph请求: https://graph.facebook.com/me?access_token=YOUR_TOKEN