我正在尝试向图形 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);
});
最佳答案
就像Sharon说的,你需要把body字段用url编码的方式。
你可以用 jquery 来做,比如:
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 : $.param(opts) }
]
}, function (response) {
console.log(response);
});
效果不错。
关于javascript - 使用 facebook 批量请求 javascript api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14933641/