PHP code example of stevenmaguire / trello-php
1. Go to this page and download the library: Download stevenmaguire/trello-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stevenmaguire / trello-php example snippets
$client = new Stevenmaguire\Services\Trello\Client(array(
'callbackUrl' => 'http://your.domain/oauth-callback-url',
'domain' => 'https://trello.com',
'expiration' => '3days',
'key' => 'my-application-key',
'name' => 'My sweet trello enabled app',
'scope' => 'read,write',
'secret' => 'my-application-secret',
'token' => 'abcdefghijklmnopqrstuvwxyz',
'version' => '1',
'proxy' => 'tcp://localhost:8125',
));
$client = new Stevenmaguire\Services\Trello\Client(array(
'key' => 'my-application-key',
'name' => 'My sweet trello enabled app',
));
$config = array(
'callbackUrl' => 'http://your.domain/oauth-callback-url',
'expiration' => '3days',
'scope' => 'read,write',
);
$client->addConfig($config);
$client = new Stevenmaguire\Services\Trello\Client(array(
'key' => 'my-application-key',
'name' => 'My sweet trello enabled app',
));
$client->addConfig('token', 'abcdefghijklmnopqrstuvwxyz');
$client = new Stevenmaguire\Services\Trello\Client(array(
'key' => 'my-application-key',
'secret' => 'my-application-secret',
));
$config = array(
'name' => 'My sweet trello enabled app',
'callbackUrl' => 'http://your.domain/oauth-callback-url',
'expiration' => '3days',
'scope' => 'read,write',
);
$client->addConfig($config);
$authorizationUrl = $client->getAuthorizationUrl();
header('Location: ' . $authorizationUrl);
$token = $_GET['oauth_token'];
$verifier = $_GET['oauth_verifier'];
$credentials = $client->getAccessToken($token, $verifier);
$accessToken = $credentials->getIdentifier();
$client->addConfig('token', $accessToken);
$user = $client->getCurrentUser();
$client = new Stevenmaguire\Services\Trello\Client(array(
'key' => 'my-application-key',
'token' => 'your-users-access-token',
));
$boards = $client->getCurrentUserBoards();
$cards = $client->getCurrentUserCards();
$organizations = $client->getCurrentUserOrganizations();
try {
$board = $client->getBoard($boardId);
} catch (Stevenmaguire\Services\Trello\Exceptions\Exception $e) {
$code = $e->getCode(); // Http status code from response
$reason = $e->getMessage(); // Http status reason phrase
$error = $e->getPrevious(); // GuzzleHttp\Exception\RequestException from http client
$body = $e->getResponseBody(); // stdClass response body from http client
}
bash
$ composer