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

javascript - FB.api error.. "An access token is required to request this resource" - Stack Overflow

programmeradmin1浏览0评论
FB.api('/1354376857/groups', function(response){
     Data = response.name;
     alert(Data);

     if (response.error) {
        alert(response.error.message);
     }  
});

The outputted error message reads: "An access token is required to request this resource" and Data content is undefined for my Facebook app. The user is successfully logged in and the "user_groups" permission has been approved by the user.

I was under the impression that FB.api automatically sets the access token. Any thoughts on why this error is occurring?

FB.api('/1354376857/groups', function(response){
     Data = response.name;
     alert(Data);

     if (response.error) {
        alert(response.error.message);
     }  
});

The outputted error message reads: "An access token is required to request this resource" and Data content is undefined for my Facebook app. The user is successfully logged in and the "user_groups" permission has been approved by the user.

I was under the impression that FB.api automatically sets the access token. Any thoughts on why this error is occurring?

Share Improve this question edited Aug 15, 2015 at 2:34 Pang 10.1k146 gold badges86 silver badges124 bronze badges asked Dec 10, 2013 at 3:36 user3085287user3085287 231 silver badge3 bronze badges 2
  • Use access token along with the request stackoverflow./questions/4758770/… – Surabhil Sergy Commented Dec 10, 2013 at 3:43
  • Thank you Surabhil.. You're guidance was essential to solving the problem. – user3085287 Commented Dec 10, 2013 at 17:11
Add a ment  | 

1 Answer 1

Reset to default 7

Change your code to this

var token = "YOUR_TOKEN";
FB.api('/1354376857/groups', function(response){
     Data = response.name;
     alert(Data);
     if (response.error) {
        alert(response.error.message);
     }  
}, {access_token: token});

You must pass your access token every time you do a request to the facebook api.

发布评论

评论列表(0)

  1. 暂无评论