You are here

public function KalturaClientBase::doQueue in Kaltura 6.2

* Call all API service that are in queue * *

Return value

unknown

1 call to KalturaClientBase::doQueue()
KalturaClientBase::doMultiRequest in kaltura_client/KalturaClientBase.php

File

kaltura_client/KalturaClientBase.php, line 70

Class

KalturaClientBase

Code

public function doQueue() {
  if (count($this->callsQueue) == 0) {
    return null;
  }
  $startTime = microtime(true);
  $params = array();
  $files = array();
  $this
    ->log("service url: [" . $this->config->serviceUrl . "]");

  // append the basic params
  $this
    ->addParam($params, "apiVersion", self::KALTURA_API_VERSION);
  $this
    ->addParam($params, "format", $this->config->format);
  $this
    ->addParam($params, "clientTag", $this->config->clientTag);
  $url = $this->config->serviceUrl . "/api_v3/index.php?service=";
  if ($this->isMultiRequest) {
    $url .= "multirequest";
    $i = 1;
    foreach ($this->callsQueue as $call) {
      $callParams = $call
        ->getParamsForMultiRequest($i++);
      $params = array_merge($params, $callParams);
      $files = array_merge($files, $call->files);
    }
  }
  else {
    $call = $this->callsQueue[0];
    $url .= $call->service . "&action=" . $call->action;
    $params = array_merge($params, $call->params);
    $files = $call->files;
  }

  // reset
  $this->callsQueue = array();
  $this->isMultiRequest = false;
  $signature = $this
    ->signature($params);
  $this
    ->addParam($params, "kalsig", $signature);
  list($postResult, $error) = $this
    ->doHttpRequest($url, $params, $files);
  if ($error) {
    throw new Exception($error);
  }
  else {
    $this
      ->log("result (serialized): " . $postResult);
    if ($this->config->format == self::KALTURA_SERVICE_FORMAT_PHP) {
      $result = @unserialize($postResult);
      if ($result === false && serialize(false) !== $postResult) {
        throw new Exception("failed to serialize server result\n{$postResult}");
      }
      $dump = print_r($result, true);
      $this
        ->log("result (object dump): " . $dump);
    }
    else {
      throw new Exception("unsupported format");
    }
  }
  $endTime = microtime(true);
  $this
    ->log("execution time for [" . $url . "]: [" . ($endTime - $startTime) . "]");
  return $result;
}