basecamp api多个待办事项

时间:2014-03-06 00:46:38

标签: php api basecamp

我目前正致力于对basecamp进行简单的api调用,我已设法设置:

  • 新项目
  • todo list
  • todo列表项目

目前我正在通过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);
}

1 个答案:

答案 0 :(得分:0)

无法在单个请求中添加多个待办事项。您需要为每个待办事项发出单独的POST请求。如果您保持在我们的费率限制范围内(https://github.com/basecamp/bcx-api#rate-limiting),一切都应该是好的:)