通过trello api创建团队/组织

时间:2016-08-15 10:26:36

标签: php trello

我想通过网站上的html表单自动创建trello团队。

我写了一个似乎有效的PHP脚本。例如,我可以获得电路板列表或创建新电路板。但它不适合创建团队。

HTML CODE

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>

<form action="api_method.php" method="post">
  Project Name:<br>
  <input type="text" name="projectName" value="board_test">
  <br><br>
  <input type="submit" value="Submit">
</form> 

<p>If you click the "Submit" button, the form-data will be sent to a page called "api_method.php".</p>

</body>
</html>

然后我使用php脚本创建新板:

<?php
require("trello_api.php");
$key = 'mykey';
$token = 'mytoken';
$trello = new trello_api($key, $token);

$data = $trello->request('GET', ('member/me/boards'));

$obj = array('name' => $_POST['projectName']);


$trello->request('POST', ('/boards'),$obj);


echo "Board name: " . $data[0]->name . "\n \n";
echo "New board: " . $_POST['projectName'];

?>

这样做完美但不是当我尝试用&#34;组织&#34;做同样的事情时它不起作用

$trello->request('POST', ('/organizations'),$obj);
你能帮我吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,我不得不使用选项&#34; displayName&#34;而不是&#34; name&#34;

<?php
require("trello_api.php");
$key = 'myKey';
$token = 'myToken';
$trello = new trello_api($key, $token);

$data = $trello->request('GET', ('member/me/boards'));

$obj = array('displayName' => $_POST['projectName']);


$trello->request('POST', ('/organizations'),$obj);


echo "Board name: " . $data[0]->name . "\n \n";
echo "New board: " . $_POST['projectName'];

?>