我目前正在对basecamp进行一个简单的api调用,我已经成功地设置了:
目前,我正在通过api的php包装器(可以在这里找到https://github.com/bdunlap/basecamp.php)和一个foreach循环来完成这一工作。但这需要很长时间,我怀疑这是实现这一目标的最佳途径。
我的问题是:一次可以添加多个待办项目吗?理想情况下,我想增加20个项目。github上的文档只声明添加了一个条目(https://github.com/basecamp/bcx-api/blob/master/sections/todos.md#create-todo),我尝试过嵌套数组,但没有成功。
我使用过的代码如下
/*** Create a new todo list:*/
$todolist =array('name' => 'Post Project', 'description' => 'Things to complete after project is completed');
$ProjectToDoList = $basecamp('POST', '/projects/'.$newProject->id.'/todolists.json', $todolist);
echo "Post Project Todo List ID is {$ProjectToDoList->id}\n";
/*** just incase i want to add due dates in the future *****/
//array('content' => '3 month review contact client'),
/*** just incase i want to add due dates in the future *****/
/*** Add todo items to the Post Project list ****/
$todoItems = array(
array('content' => 'User guide supplied'),
array('content' => 'Client Training Completed'),
array('content' => '3 month review contact client'),
array('content' => 'Add to mailchimp mailing list and set up auto responder')
);
foreach($todoItems as $todoItem){
$ToDoListItem = $basecamp('POST', '/projects/'.$newProject->id.'/todolists/'.$ProjectToDoList->id.'/todos.json', $todoItem);
}发布于 2014-03-06 16:09:37
在一个请求中添加多个待办事项是不可能的。您需要为每个待办事项提出一个单独的帖子请求。如果你保持在我们的利率限制(https://github.com/basecamp/bcx-api#rate-limiting)内,一切都应该是-ok :)
https://stackoverflow.com/questions/22212613
复制相似问题