PHP code example of timothydc / exact-online-base-client

1. Go to this page and download the library: Download timothydc/exact-online-base-client 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/ */

    

timothydc / exact-online-base-client example snippets


use TimothyDC\ExactOnline\BaseClient\ExactOnlineClient;
use TimothyDC\ExactOnline\BaseClient\ClientConfiguration;
use TimothyDC\ExactOnline\BaseClient\Authentication\TokenVault;
use Psr\Log\LogLevel;

$clientConfiguration = new ClientConfiguration(
    'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // client ID
    'yyyy', // client secret
    'zzzz',  // webhook secret
    'your-public-callback-url', // redirect URL - should be _exactly_ the same as the URL defined in the EOL app center
    'https://start.exactonline.be' // API base URL. Note the ".be" for Belgium
 );

$tokenVault = new TokenVault();
$tokenVault->setStoragePath('path/to/tokens.json');

$client = new ExactOnlineClient($clientConfiguration, $tokenVault);
$client->setLogger($this->logger); // optional logging
$client->setDefaultLogLevel(LogLevel::ERROR); // optional log level

$client->startAuthorization();

$client->completeAuthorization('code-from-query-parameters');

use Picqer\Financials\Exact\Item;

$items = (new Item($client->getConnection()))->get();

$client->disconnect();

use Picqer\Financials\Exact\Item;

$items = (new Item($client->getConnection('FR-BE')))->get();

use TimothyDC\ExactOnline\BaseClient\Interfaces\AccessTokenInterface;
use TimothyDC\ExactOnline\BaseClient\Interfaces\TokenVaultInterface;

class TokenVault implements TokenVaultInterface
{
    public function makeToken(?string $accesToken, ?string $refreshToken, int $expiresAt): AccessTokenInterface
    {
    }
    
    public function store(AccessTokenInterface $accessToken): void
    {
    }
    
    public function retrieve(): AccessTokenInterface
    {
    }
    
    public function clear(): void
    {
    }
}

use TimothyDC\ExactOnline\BaseClient\Interfaces\AccessTokenInterface;

class Token implements AccessTokenInterface
{
    public function getAccessToken(): ?string
    {
    }
    
    public function getRefreshToken(): ?string
    {
    }
    
    public function getExpiresAt(): int
    {
    }
}