- Модуль: socialservices
- Путь к файлу: ~/bitrix/modules/socialservices/classes/general/bitrixservice.php
- Класс: CBitrixServiceTransport
- Вызов: CBitrixServiceTransport::call
public function call($methodName, $additionalParams = null, $licenseCheck = false)
{
global $APPLICATION;
if($this->clientId && $this->clientSecret)
{
if(!is_array($additionalParams))
{
$additionalParams = array();
}
else
{
$additionalParams = $APPLICATION->ConvertCharsetArray($additionalParams, LANG_CHARSET, "utf-8");
}
$additionalParams['client_id'] = $this->clientId;
$additionalParams['client_secret'] = $this->clientSecret;
if($licenseCheck)
{
$additionalParams['key'] = static::getLicense();
}
$http = new HttpClient(array('socketTimeout' => $this->httpTimeout));
$result = $http->post(
$this->serviceHost.static::SERVICE_URL.$methodName,
$additionalParams
);
$res = false;
try
{
$res = $this->prepareAnswer($result);
}
catch(BitrixMainArgumentException $e)
{
}
if($res)
{
if(!$licenseCheck && is_array($res) && isset($res['error']) && $res['error'] === 'verification_needed')
{
return $this->call($methodName, $additionalParams, true);
}
}
else
{
AddMessage2Log('Strange answer from Bitrix Service! '.$this->serviceHost.static::SERVICE_URL.$methodName.": ".$http->getStatus().' '.$result);
}
return $res;
}
else
{
throw new BitrixMainSystemException("No client credentials");
}
}