PHP code example of openeuropa / cdt-client

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

    

openeuropa / cdt-client example snippets




$client = new \OpenEuropa\CdtClient\ApiClient(
    new \GuzzleHttp\Client(),
    new \GuzzleHttp\Psr7\HttpFactory(),
    new \GuzzleHttp\Psr7\HttpFactory(),
    [
        // For a full list of options see "Configuration".
        'apiBaseUrl' => 'https://example.com',
        'username' => 'your-user-name',
        'password' => 'your-password',
        'client' => 'client-name',
    ]
);

$response = $client->checkConnection();

$response = $client->getReferenceData();

use OpenEuropa\CdtClient\Model\Request\Translation;
use OpenEuropa\CdtClient\Exception\ValidationErrorsException;

$translationRequest = new Translation()
try {
    if ($client->validateTranslationRequest($translationRequest)) {
        $correlationId = $client->sendTranslationRequest($translationRequest);
    }
} catch (ValidationErrorsException $e) {
    $errors = $e->getValidationErrors();
    // Handle the errors.
}

$permanentId = $client->getPermanentIdentifier($correlationId);

$translationStatus = $client->getRequestStatus($permanentId);

$file = $client->downloadFile($fileUrl);