FB.api错误.“请求访问令牌才能请求此资源" [英] FB.api error.. "An access token is required to request this resource"
本文介绍了FB.api错误.“请求访问令牌才能请求此资源"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
FB.api('/1354376857/groups', function(response){
Data = response.name;
alert(Data);
if (response.error) {
alert(response.error.message);
}
});
输出的错误消息显示为:需要访问令牌才能请求此资源",并且我的Facebook应用程序的数据内容未定义.用户已成功登录,并且该用户已批准"user_groups"权限.
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.
给我的印象是FB.api自动设置访问令牌.为什么会出现此错误?
I was under the impression that FB.api automatically sets the access token. Any thoughts on why this error is occurring?
推荐答案
将代码更改为此
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});
每次向Facebook api发送请求时,您都必须传递访问令牌.
You must pass your access token every time you do a request to the facebook api.
这篇关于FB.api错误.“请求访问令牌才能请求此资源"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文