[英]How to use Trello JS API to create a card
我一直在嘗試通過JSFiddle利用Trello API ,但沒有使其正常工作(我對JS / JSON的了解非常有限)。 我需要使用API在特定列表下創建卡。
function PostStuff()
{
$(document).ready(function(){
Trello.authorize({
interactive: true,
type: "popup",
expiration: "never",
name: "surveyrequest",
persist: "true",
success: function() { onAuthorizeSuccessful(); },
error: function() { onFailedAuthorization(); },
scope: { read: true, write: true}
});
function onAuthorizeSuccessful() {
Trello.post("cards", { name: "Card created for test", desc: "this is a test", idList: "........", due: null, urlSource: null});
}
});
}
我有JQuery和Trello API。 為了安全起見,我在代碼中清空了idList。 我確認該代碼確實執行了onAuthorizeSuccessful()函數。
我該如何修改才能創建Trello卡?
function Auth() {
Trello.authorize({
type: 'popup',
name: 'your app name',
scope: {
read: true,
write: true },
expiration: '30days',
success: authenticationSuccess,
error: authenticationFailure
});
var authenticationSuccess = function(data){ /*your function stuff*/};
var authenticationFailure = function(data){ /*your function stuff*/};
}
該代碼對我有用。 我單擊按鈕時觸發了函數Auth()。
另外,令牌可能已過期,因此可能會出現一些問題,因此Trello.deauthorize();
可能會導致令牌Trello.deauthorize();
可用於創建新卡失敗功能(這完全取決於創建新卡錯誤消息)。
關於創建新卡...
var newCard =
{name: jQuery('input#tc_title').val(),
desc: jQuery('textarea#tc_desc').val(),
pos: "top",
idList: trello_list_id_var
};
Trello.post('/cards/', newCard, success, error);
var success = function(data){ /*..............*/}
var error= function(data){ /*..............*/}
在成功/錯誤功能中,您可以檢查錯誤數據
編輯:我也認為Trello.post("cards" ...
應該用Trello.post("/cards/" ...
替換Trello.post("/cards/" ...
可能是問題所在...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.