我正在学习Trello API,但在大多数情况下并不困难。但是,批处理GET请求的批处理方法具有最小化流量等的实际潜力。但是,我无法让它发挥作用。它总是抱怨无效的令牌。虽然如果我将令牌附加到GET URL中,它似乎并不重要。
任何人都有工作批处理示例吗? (在浏览器中工作的简单URL字符串?)
谢谢!
答案 0 :(得分:1)
这对我有用......
https://api.trello.com/1/batch?urls=/members/me/boards,/members/me&key=YOUR_KEY&token=YOUR_TOKEN
同时从'/ members / me / boards'和'/ members / me'获取。
让Client.js登录并为您获取数据(它也为您获取密钥和令牌)会更容易一些。试试这个......
// Call this function
function trelloBatchTest() {
// Try to log into Trello before getting data
if (Trello.authorized() === false) {
Trello.authorize({
type: "popup",
interactive: true,
scope: { read: true, write: true, account: true },
success: function () {
getBatchData();
},
error: function () {
console.log("error logging in");
}
});
}
// Get data straight away if already logged in
else {
getBatchData();
}
}
// Makes a batch GET request to Trello - called from function above
function getBatchData() {
Trello.get("/batch?urls=/members/me/boards,/members/me", function(data) {
console.log(data);
}, function (error){
console.log(error);
});
}
希望有所帮助:)