1
我想我已經嘗試了這裏的所有解決方案,並且它們都不適合我。Trello不會在使用Google應用程序腳本的列表之間移動卡片
問題是我不能使用trello API在列表之間移動卡片。我曾嘗試這個方法可以做到這一點:
數1:
var API_KEY = '********************************';
var TOKEN = '************************************************************';
var ID_LIST = '***************************';
var payload = {
"value": ID_LIST,
"token": TOKEN,
"key": API_KEY
};
var options = {
"method": "PUT",
"payload": payload
};
// Post the payload to Trello
try {
var response = UrlFetchApp.fetch('http://api.trello.com/1/cards/[id of my card]/idList', options);
Logger.log(response);
} catch (e) {
// Log any errors
Logger.log("ERROR:\n"+e.message);
}
數2:
function createOAthService_Trello() {
var consumerKey='*************************';
var consumerSecret = '********************************************************'
var service = OAuth1.createService("trello");
service.setAccessTokenUrl("https://trello.com/1/OAuthGetAccessToken");
service.setRequestTokenUrl("https://trello.com/1/OAuthGetRequestToken");
service.setAuthorizationUrl("https://trello.com/1/OAuthAuthorizeToken?scope=read,write");
service.setPropertyStore(PropertiesService.getScriptProperties());
service.setCallbackFunction('authCallback_Trello');
service.setConsumerKey(consumerKey);
service.setConsumerSecret(consumerSecret);
return service;
}
function checkServiceAccess(){
var service = createOAthService_Trello();
var emailAddress ='*****@********.com';
if(service.hasAccess()){
return service;
}
else {
var authorizationUrl = service.authorize();
MailApp.sendEmail(emailAddress, 'Google Script App Needs Authorization (Trello)', 'Please visit the following URL and then re-run the script: ' + authorizationUrl);
Logger.log('Please visit the following URL and then re-run the script: ' + authorizationUrl);
}
}
function moveCard(){
var service = checkServiceAccess();
var url = 'http://api.trello.com/1/cards/[myCardId]/idList?value=[newListId]&token=[myToken]&cards=open&lists=open'
var options = {"method" : "put"};
var raw= service.fetch(url, options);
Logger.log(raw);
}
的代碼這兩塊不會崩潰。但他們不移動任何卡,只返回一個帶有他們所在列表ID的日誌。
我已經檢查了一千次的id是否正確,以至於不能成爲問題。 對於PUT請求來說,它似乎沒有問題,因爲我可以更新說明,標題......但是,通過DELETE請求,它會觸發「意外的異常」。也許他們是相關的。
另外,我還試圖插入這對我的代碼:
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="https://trello.com/1/client.js?key=*****************************"></script>
</html>
//eval(UrlFetchApp.fetch('https://trello.com/1/client.js?key=************************').getContentText());
var success = function(successMsg) {
asyncOutput(successMsg);
};
var error = function(errorMsg) {
asyncOutput(errorMsg);
};
Logger.log(Trello.get('/member/me/boards', success, error));
但它崩潰,因爲它無法找到Trello全局變量。 我真的很絕望,任何幫助都會令人失望。 謝謝你的時間! :)
如果您可以使用其他trello調用成功,很可能您在api使用中出現錯誤。最後一次嘗試不能工作,因爲trello庫用於前端使用,而不是後端使用。 –
我認爲這可能是,所以我嘗試在Trello的沙箱,它的工作。但他們使用全球Trello對象... –
您可以嘗試使用Chrome調試器在控制檯中使用JavaScript進行api調用。 –