【发布时间】:2013-02-18 10:01:56
【问题描述】:
我正在尝试向图形 api 发送批处理请求,并在第二个请求的响应中出错:
"{
"error": {
"message": "(#100) Missing message or attachment",
"type": "OAuthException",
"code": 100
}
}"
谁能告诉我我做错了什么?
这是我使用的代码:
var opts = {
message : 'Some message',
name : 'Post Name',
link : 'url',
description : 'The post Description',
picture : 'url to image'
};
FB.api('/', 'POST', {
batch: [
{ method: 'GET', relative_url: 'me/friends'},
{ method: "POST",relative_url: "me/feed", body : opts }
]
}, function (response) {
console.log(response);
});
【问题讨论】:
-
我认为在使用/访问 FB Graph API 的某些部分时,您需要以某种方式验证您的请求。 OAuthException 似乎表示授权错误。
-
第一个请求顺利进行,没有错误,第二个请求得到错误..即使我在单独的 API 请求中执行它,它也可以工作 FB.api('/me/feed', ' post', opts, function(response) { if (!response || response.error) { } else { } });
-
发现问题及解决方法:body字段。这应该格式化为原始 HTTP POST 正文字符串,类似于 URL 查询字符串 github.com/jgorset/facepy/issues/55
标签: javascript facebook api batch-file request