PHP code example of vasyaxy / php-trello-api

1. Go to this page and download the library: Download vasyaxy/php-trello-api 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/ */

    

vasyaxy / php-trello-api example snippets




namespace App;

use Trello\Client;

class TrelloApi
{
    public Client|null $client;

    public function __construct()
    {
        $this->client = new Client();
    }
    
    public function setupTrelloClient(): void
    {
        $this->client->authenticate(
            'API_KEY',                            // Api key - get from https://dashboard.stripe.com/test/apikeys7
            'USER_TOKEN (empty)',                 // Empty for this exampe
            Client::AUTH_URL_CLIENT_ID            // nvm
        );
    }

    public function getAuthUrl(): string
    {
        $this->setupTrelloClient();

        return $this->client->getAuthUrl([
            'key' => 'API_KEY',                   // Api key - get from https://trello.com/power-ups/admin - NEW - get key
            'secret' => 'API_SECRET',             // ^^^ "Reveal test key"
            'callbackUrl' => '!!CALL_BACK_URL!!', // example: 'http://mymegatite.com/trello-hook/'
            'name' => 'My Mega Trello App!!!1',   // nvm
            'expiration' => 'never',              // >> MH <<
            'scope' => 'read,write',              // >> MH <<
        ]);
    }
}

use Trello\Client;

$client = new Client();
$client->authenticate('API_KEY', 'USER_KEY', Client::AUTH_URL_CLIENT_ID);
$boards = $client->api('member')->boards()->all();

use Trello\Client;
use Trello\Manager;

$client = new Client();
$client->authenticate('API_KEY', 'USER_KEY', Client::AUTH_URL_CLIENT_ID);

$manager = new Manager($client);

$card = $manager->getCard('547440ad3f8b882bc11f0497');

$card
    ->setName('Test card')
    ->setDescription('Test description')
    ->save();

use Trello\Client;
use Trello\Service;
use Trello\Events;

$client = new Client();
$client->authenticate('API_KEY', 'USER_KEY', Client::AUTH_URL_CLIENT_ID);

$service = new Service($client);

// Bind a callable to a given event...
$service->addListener(Events::BOARD_UPDATE, function ($event) {
    $board = $event->getBoard();

    // do something
});

// Check if the current request was made by a Trello webhook
// This will dispatch any Trello event to listeners defined above
$service->handleWebhook();
bash
$ composer