You are here

function uploadContextDemo in TMGMT Translator Smartling 8.2

Same name in this branch
  1. 8.2 api-sdk-php/examples/context-example.php \uploadContextDemo()
  2. 8.2 vendor/smartling/api-sdk-php/examples/context-example.php \uploadContextDemo()
Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/examples/context-example.php \uploadContextDemo()
  2. 8.3 vendor/smartling/api-sdk-php/examples/context-example.php \uploadContextDemo()

Parameters

\Smartling\AuthApi\AuthApiInterface $authProvider:

string $projectId:

string $fileUri:

Return value

array

2 calls to uploadContextDemo()
context-example.php in api-sdk-php/examples/context-example.php
context-example.php in vendor/smartling/api-sdk-php/examples/context-example.php

File

api-sdk-php/examples/context-example.php, line 56

Code

function uploadContextDemo($authProvider, $projectId, $fileUri) {
  $response = false;
  $context = \Smartling\Context\ContextApi::create($authProvider, $projectId);
  $params = new UploadContextParameters();
  $params
    ->setContextFileUri($fileUri);
  $params
    ->setName('context.html');
  $st = microtime(true);
  try {
    $response = $context
      ->uploadContext($params);
  } 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;
}