2016-08-15 99 views
0

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

我写了一个似乎工作的PHP脚本。例如,我可以获得董事会名单或创建一个新的董事会。但它不适用于创建团队。

HTML代码

<!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']; 

?> 

使作品完美,但不是当我尝试做同样的事情用“组织”它不起作用

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

你能帮我吗。

+0

你什么错误?什么不起作用? _“它不起作用”_并不真的让我们有很多工作与 – Epodax

+0

它根本不创建团队。我只是从文档https://developers.trello.com/advanced-reference/organization#post-1-organizations复制函数 –

回答

0

我找到了解决办法,我只好用选项“显示名”,而不是“名”

<?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']; 

?>