PHP code example of traffic-orchestrator / sdk

1. Go to this page and download the library: Download traffic-orchestrator/sdk 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/ */

    

traffic-orchestrator / sdk example snippets


use TrafficOrchestrator\Client;

$to = new Client();
$result = $to->validateLicense('LK-xxxx', 'example.com');

if ($result->valid) {
    echo "Plan: " . $result->planId;
}

$to = new Client(['apiKey' => getenv('TO_API_KEY')]);
$licenses = $to->listLicenses();

$to = new Client([
    'apiKey' => getenv('TO_API_KEY'),
    'timeout' => 5,
    'retries' => 3,  // Retry on 5xx with backoff
]);

// Production (default)
$to = new Client(['apiKey' => getenv('TO_API_KEY')]);

// Staging
$to = new Client([
    'apiKey' => getenv('TO_API_KEY_DEV'),
    'apiUrl' => 'https://api-staging.trafficorchestrator.com/api/v1',
]);

$to = new Client([
    'publicKey' => getenv('TO_PUBLIC_KEY'),
]);
$result = $to->verifyOffline($licenseToken);
if ($result->valid) {
    echo "Plan: " . $result->planId;
}