PHP code example of cervon / tms-php-client

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

    

cervon / tms-php-client example snippets


use Cervon\Tms\Tms;

$CLIENT_ID = 'MY_CLIENT_ID';
$CLIENT_SECRET = 'MY_CLIENT_SECRET';
$TMS_BASE_URL = 'https://my-tms-url.com/'

$tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL);
$authenticator = $tms->getAccessToken();
$tms->authenticate($authenticator);

$jobs = $tms->listJobs();

foreach ($jobs as $job) {
    echo "Job #{$job->number} (ID: {$job->_id})\n";
}

use Cervon\Tms\Tms;

$CLIENT_ID = 'MY_CLIENT_ID';
$CLIENT_SECRET = 'MY_CLIENT_SECRET';
$TMS_BASE_URL = 'https://my-tms-url.com/'

$tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL);
$authenticator = $tms->getAccessToken();

$tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL, verifySsl: false);

use Cervon\Tms\Tms;
use Illuminate\Support\Facades\Cache;

$tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL);

$authenticator = Cache::remember('tms_authenticator', 3600, function () use ($tms) {
    // Fresh token when cache is empty
    return $tms->getAccessToken();
});

// Refresh token when expired
if ($authenticator->hasExpired()) {
    $authenticator = $tms->getAccessToken();
    Cache::put('tms_authenticator', $authenticator, 3600);
}

$tms->authenticate($authenticator);
bash
composer