You are here

function uploadBatchFileDemo in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/examples/batch-example.php \uploadBatchFileDemo()

Parameters

\Smartling\AuthApi\AuthApiInterface $authProvider:

string $projectId:

int $batchUid:

Return value

bool

1 call to uploadBatchFileDemo()
batch-example.php in vendor/smartling/api-sdk-php/examples/batch-example.php

File

vendor/smartling/api-sdk-php/examples/batch-example.php, line 90

Code

function uploadBatchFileDemo($authProvider, $projectId, $batchUid) {
  echo "--- Upload file ---\n";
  $response = [];
  $batchApi = BatchApi::create($authProvider, $projectId);
  $uploadParameters = new UploadFileParameters();
  $uploadParameters
    ->setLocalesToApprove([
    'fr-FR',
  ]);
  $st = microtime(true);
  try {
    $response = $batchApi
      ->uploadBatchFile(realpath('../tests/resources/test.xml'), 'test-BATCH-file.xml', 'xml', $batchUid, $uploadParameters);
  } catch (\Smartling\Exceptions\SmartlingApiException $e) {
    var_dump($e
      ->getErrors());
  }
  $et = microtime(TRUE);
  $time = $et - $st;
  echo vsprintf('Request took %s seconds.%s', [
    round($time, 3),
    "\n\r",
  ]);
  if (!empty($response)) {
    var_dump($response);
  }
  return $response;
}