public static function TrelloAPI($token) { $client = new Trello\Client(); $client->authenticate('658f0e49767a334eb04b65d1c43167b4', $token, Client::AUTH_URL_CLIENT_ID); // Get list boards $boards = $client->api('member')->boards()->all("me", array()); $boardNUM = 0; $boardID = ""; $listID = ""; foreach ($boards as $board) { $boardID = $board['id']; echo $boardNUM++ . "/ " . "<a style='background-color: red;'>--------Board name</a>: " . $board['name'] . "<br/>" . " - Board ID: " . $boardID; echo "<br/>"; echo "------------------------"; echo "<br/>"; // Get list of boards echo "List of boards"; echo "<br/>"; $lists = $client->api('boards')->lists()->all("{$boardID}", array()); foreach ($lists as $list) { $listID = $list['id']; echo "+" . "<a style='background-color: green;'> List name: </a>" . $list['name'] . "<br/>" . "List ID: " . $list['id']; echo "<br/>"; $cards = $client->api('lists')->cards()->all("{$listID}", array()); foreach ($cards as $card) { echo "+" . "<a style='background-color: blue;'> Card name: </a>" . $card['name'] . "<br/>"; echo "Deadline: " . $card['due'] . "<br/>"; echo "Description: " . $card['desc'] . "<br/>"; } } } }
/** * Client constructor * * @param Repository $config */ public function __construct(Repository $config) { // Get the config data $this->config = $config; // Make the client instance $this->client = new Client(); $this->client->authenticate($this->config->get('trello.api_key'), $this->config->get('trello.api_token'), Client::AUTH_URL_CLIENT_ID); }
/** * @param Cardlist $list * * @return float|int */ public function countListStoryPoints(Cardlist $list) { $cards = $this->client->api('list')->cards()->all($list->getId()); $totalSP = 0; foreach ($cards as $card) { if (!$card['closed']) { $totalSP += $this->parseStoryPoints($card['name']); } } return $totalSP; }
/** * Return in instance of Board get from the board name. * * @param string $boardName * * @return \Trello\Model\Board|null */ public function getBoard(string $boardName) { $boards = $this->client->api('member')->boards()->all('me'); foreach ($boards as $board) { if ($board['name'] == $boardName) { $boardId = $board['id']; } } $manager = new Manager($this->client); if (!isset($boardId)) { return; } return $manager->getBoard($boardId); }
/** * @param string $listName * @param array $boards * * @return Cardlist|void * * @throws \Exception */ public function getList(string $listName, array $boards) { $lists = []; foreach ($boards as $board) { if (!$board instanceof Board) { throw new \Exception('Function ListManager::getList expect an array of Board as second argument'); } $lists = array_merge($lists, $this->client->api('board')->lists()->all($board->getId())); } foreach ($lists as $list) { if ($list['name'] == $listName) { return new Cardlist($this->client, $list['id']); } } return; }
/** * @param array $todoLists * @param array $wipLists * @param array $doneLists * * @return array */ public function getCardsMovedFromTodoToDone(array $todoLists, array $wipLists, array $doneLists) { // Get all actions on done lists. $actionsOnDoneLists = []; foreach ($doneLists as $list) { $actionsOnDoneLists = array_merge($actionsOnDoneLists, $this->client->api('lists')->actions()->all($list->getId(), ['filter' => 'updateCard', 'limit' => '100'])); } // Get all done cards $doneCards = []; foreach ($doneLists as $list) { $doneCards = array_merge($doneCards, $this->client->api('lists')->cards()->all($list->getId())); } // Get ids of done cards $doneCardIds = []; foreach ($doneCards as $card) { $doneCardIds[] = $card['id']; } // Get todo list Ids $todoListsIds = []; foreach ($todoLists as $list) { $todoListsIds[] = $list->getId(); } // Get wip list Ids $wipListsIds = []; foreach ($wipLists as $list) { $wipListsIds[] = $list->getId(); } // Get done list Ids $doneListsIds = []; foreach ($doneLists as $list) { $doneListsIds[] = $list->getId(); } $cardFromTodoToDone = []; foreach ($actionsOnDoneLists as $action) { if ($action['type'] == 'updateCard' && isset($action['data']['listBefore']) && isset($action['data']['listAfter']) && (in_array($action['data']['listBefore']['id'], $todoListsIds) && in_array($action['data']['old']['idList'], $todoListsIds) || in_array($action['data']['listBefore']['id'], $wipListsIds) && in_array($action['data']['old']['idList'], $wipListsIds)) && in_array($action['data']['listAfter']['id'], $doneListsIds) && in_array($action['data']['card']['id'], $doneCardIds)) { if (!isset($cardFromTodoToDone[$action['data']['card']['id']])) { $cardFromTodoToDone[$action['data']['card']['id']] = ['date' => $action['date'], 'card' => $action['data']['card']['name']]; } elseif ($action['date'] > $cardFromTodoToDone[$action['data']['card']['id']]['date']) { $cardFromTodoToDone[$action['data']['card']['id']] = ['date' => $action['date'], 'card' => $action['data']['card']['name']]; } } } return $cardFromTodoToDone; }
<?php //namespace Trello; // require "HttpClient/HttpClientInterface.php"; // require "HttpClient/HttpClient.php"; // require "Client.php"; // require '../../vendor/autoload.php'; // use \Trello\HttpClient\HttpClientInterface; // use \Trello\HttpClient\HttpClient; use Trello\Client; $client = new Client(); //$client->authenticate('658f0e49767a334eb04b65d1c43167b4', '77e308573b49ba9e498e4371df88402fc8e33a08ded0eaed9b9e41b893155a1e', Client::AUTH_URL_CLIENT_ID); $client->authenticate('658f0e49767a334eb04b65d1c43167b4', 'da5d95a64591f6e44948221dce3c611e1fd993ea4902f3ef997f6a6e8ddcd762', Client::AUTH_URL_CLIENT_ID); // $boards = $client->api('member')->boards()->all("me", array()); // //print_r($boards); $board_id = ""; foreach ($boards as $board) { //print_r($board); //Voi moi board: $board_id = $board["id"]; echo "name->" . $board["name"] . ", id->{$board_id}"; echo "<br/ >"; } $board_id = "55dac641076bcf0fc17be2f9"; //list card cua cua board: echo "<br /> lists board {$board_id} la: <br />"; $lists = $client->api('board')->lists()->all($board_id, array()); //print_r($lists);
/** * Send a DELETE request with JSON-encoded parameters. * * @param string $path Request path. * @param array $parameters POST parameters to be JSON encoded. * @param array $requestHeaders Request headers. * * @return mixed */ protected function delete($path, array $parameters = array(), $requestHeaders = array()) { $response = $this->client->getHttpClient()->delete($path, $this->createParametersBody($parameters), $requestHeaders); return ResponseMediator::getContent($response); }
/** * Set Client and authenticate. */ public function setClient() { $this->client = new Client(); $this->client->authenticate($this->apiKey, $this->apiToken, Client::AUTH_URL_CLIENT_ID); }
public function tickets($query) { $board = strrpos($query, '-'); $board = substr($query, 0, $board); $data = $this->workflow->read('boards.json'); foreach ($data as $result) { if (strripos($result->name, $board) !== false) { $TrelloClient = new Client($this->trello_api_key); $results = array(); $token = $this->workflow->get('trello_user_token', 'settings.plist'); $_endpoint_url = 'boards/' . $result->id . '/cards?fields=name,url,shortUrl'; // https://api.trello.com/1/boards/4eea4ffc91e31d1746000046/cards?fields=name,idList,url&key=[application_key]&token=[optional_auth_token] $data = $TrelloClient->get($_endpoint_url, array('key' => $this->trello_api_key, 'token' => $token)); foreach ($data as $card) { $number = substr($query, strrpos($query, '-') + 1); $card = substr($card['url'], strrpos($card['url'], '/') + 1); $ticket = explode("-", $card, 2); if ($ticket['0'] == $number) { $results[$card['name']]['name'] = $card['name']; $results[$card['name']]['id'] = $card['id']; $results[$card['name']]['url'] = $card['url']; $results[$card['name']]['icon'] = "./assets/card.png"; return $this->parse_results($results); } } } } }
return; } // 404.html, or 40x.html, or 4xx.html, or error.html $templates = array('errors/' . $code . '.html', 'errors/' . substr($code, 0, 2) . 'x.html', 'errors/' . substr($code, 0, 1) . 'xx.html', 'errors/default.html'); return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code); }); $app->get('/untranslated', function () use($app) { $client = new Goutte\Client(); $crawler = $client->request('GET', 'http://doc.php.net/revcheck.php?p=missfiles&lang=pt_BR'); $crawler = $crawler->filter("table > tr"); $nodeValues = $crawler->each(function (Crawler $node, $i) { $first = $node->children()->first()->text(); $last = $node->children()->last()->text(); return array($first, $last); }); $extractor = new Extractor($nodeValues); return new Response(var_dump($extractor->getFullNames())); })->bind('untranslated'); $app->get('/trello', function () use($app) { $client = new Client(); //veja aqui para gerar a key e o token de uso //https://trello.com/c/jObnWvl1/25-generating-your-developer-key $client->authenticate('afdadfasdfasfd', 'adsfasdfsdfafas', Client::AUTH_URL_CLIENT_ID); $board = $client->api('board')->show('j6Nuulpn'); $cards = $client->api('board')->cards()->all('j6Nuulpn'); $cardsNames = new \ArrayIterator(); foreach ($cards as $key => $value) { $cardsNames->append($value['name']); } return new Response(var_dump($cardsNames)); })->bind('trello');
public function actionUpdatecard() { $session = Yii::app()->session; if (isset($_POST['cardname']) && $_POST['description'] && $_POST['idCard'] && $_POST['due'] && $_POST['idList']) { $card_name = $_POST['cardname']; $des = $_POST['description']; $due = $_POST['due']; $idList = $_POST['idList']; $idCard = $_POST['idCard']; $arr = array("name" => $card_name, "desc" => $des, "due" => $due); if (isset($session['token'])) { $token = $session['token']; $client = new Trello\Client(); $client->authenticate('658f0e49767a334eb04b65d1c43167b4', $token, Client::AUTH_URL_CLIENT_ID); $cards = $client->api('cards')->update($idCard, $arr); return $this->redirect('getcardlist?listID=' . $idList); } else { echo "ko tim thay token"; exit; } } return $this->render('updatecard'); }
<?php use Trello\Client; // var_dump(file_exists(dirname(__FIle__)."/../lib/Trello/Client.php")); // // require("/../lib/Trello/Client.php"); // include dirname(__FIle__)."/../lib/Trello/Client.php"; //require_once dirname(__FIle__)."/../lib/Trello/Client.php"; $client = new Client(); $client->authenticate('658f0e49767a334eb04b65d1c43167b4', '77e308573b49ba9e498e4371df88402fc8e33a08ded0eaed9b9e41b893155a1e', Client::AUTH_URL_CLIENT_ID); $boards = $client->api('member')->boards()->all(); print_r('debug'); // exit();
public function getAuthUrl($app_name) { $endpoint_url = 'member/dberube'; $TrelloClient = new Client($this->App->trello['app_key']); return $TrelloClient->getAuthorizationUrl($app_name, $this->App->trello['auth_return_url'], array('read', 'write', 'account'), 'never', 'fragment'); }