2016-08-15 128 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']; 

?>