我目前正在对我已设法设置的 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);
}