如何使用 Trello JS API 创建卡片
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。我确认代码确实执行了onAuthorizeSuccess()函数。
如何修改此设置以创建 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();
可用于创建新卡失败功能(这完全取决于创建新卡错误消息)。
关于创建新卡...
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/" ...
......
相关文章:
- 使用Facebook live API创建实时视频对象时的隐私设置
- Javascript中的模块模式和揭示模块模式是否仅在创建API时有用;s
- SoundCloud API-基于系统中的ID创建用户配置文件
- 为node.js创建一个动态的restful api
- 使用html5地理位置api创建地理围栏
- 使用javascript api创建youtube的屏幕截图
- Facebook JavaScript API 是否适合创建用户帐户
- 使用 API 注册创建节点.js API 框架
- 如何将头添加到ActiveResource以创建API请求
- 使用 SwaggerJS 创建 API 工厂
- 什么'是通过用于MongoDB的RESTful JSON接口创建API的最快方法
- 模拟JSP's post方法与创建API相比
- 为twitter创建API以显示最新的5个帖子
- Web页面到API:从HTML元素创建API
- 如何使用express从单独的文件为客户端创建api
- 如何在React FLUX中创建API调用
- 环回组件存储创建api来显示文件夹
- 我如何创建API或链接到我的SVG,以便其他网站可以显示它
- 克服同源策略,以便创建api
- 如何为任何网站创建 API