public function call($action, $options, $path = '/')
{
if (substr($path, -1) !== '/') {
$path .= '/';
}
$this->lastApiCall = null;
$options['Action'] = isset($options['Action']) ? $options['Action'] : $action;
$options['Version'] = isset($options['Version']) ? $options['Version'] : $this->getApiVersion();
$this->lastApiCall = $options['Action'];
if (isset($options['_host'])) {
$host = $options['_host'];
unset($options['_host']);
} else {
$host = $this->url;
}
if (isset($options['_region'])) {
$region = $options['_region'];
unset($options['_region']);
} else {
$region = null;
}
if (strpos($host, 'http') === 0) {
$arr = parse_url($host);
$scheme = $arr['scheme'];
$host = $arr['host'] . (isset($arr['port']) ? ':' . $arr['port'] : '');
$path = (!empty($arr['path']) && $arr['path'] != '/' ? rtrim($arr['path'], '/') : '') . $path;
} else {
$scheme = 'https';
}
$httpRequest = $this->createRequest();
$httpRequest->addHeaders(['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8', 'Cache-Control' => 'no-cache']);
$httpRequest->setRequestUrl($scheme . '://' . $host . $path);
$httpRequest->setRequestMethod("POST");
$httpRequest->append($options);
if (true) {
$this->signRequestV4($httpRequest, $region);
} else {
$this->signRequestV2($httpRequest);
}
$response = $this->tryCall($httpRequest);
if ($this->getAws() && $this->getAws()->getDebug()) {
echo "\n", "{$httpRequest}\n", "{$response->getResponse()}\n";
}
return $response;
}