Copy these files into a new directory, then run composer install
, then get your API key and token, then run.
Created
September 15, 2017 15:32
-
-
Save jimmysawczuk/88dff03ddc4bb9547326ac8654a3577e to your computer and use it in GitHub Desktop.
Close all daily boards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"guzzlehttp/guzzle": "^6.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$client = new GuzzleHttp\Client; | |
// Generate an API key and token from this page: https://trello.com/app-key | |
$api_key = '<YOUR API KEY HERE>'; | |
$token = '<YOUR TOKEN HERE>'; | |
$username = '<YOUR USERNAME>'; | |
$boards = json_decode($client->request('GET', "https://api.trello.com/1/members/{$username}", [ | |
'query' => [ | |
'key' => $api_key, | |
'token' => $token, | |
], | |
])->getBody(), true); | |
foreach ($boards['idBoards'] as $boardID) { | |
$board = json_decode($client->request('GET', "https://api.trello.com/1/boards/{$boardID}", [ | |
'query' => [ | |
'key' => $api_key, | |
'token' => $token, | |
], | |
])->getBody(), true); | |
// Only want to consider personal boards | |
if ($board['idOrganization'] !== null) { | |
continue; | |
} | |
// If the board is already closed, we can skip it. | |
if ($board['closed']) { | |
continue; | |
} | |
if (preg_match('#^[A-Za-z]+ \d{1,2}, \d{4}#', $board['name'])) { | |
echo "To be closed: {$board['name']}\n"; | |
$res = $client->request('PUT', "https://api.trello.com/1/boards/{$boardID}", [ | |
'query' => [ | |
'key' => $api_key, | |
'token' => $token, | |
'closed' => 'true', | |
], | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment