• Модуль: bitrixcloud
  • Путь к файлу: ~/bitrix/modules/bitrixcloud/classes/general/webservice.php
  • Класс: CBitrixCloudWebService
  • Вызов: CBitrixCloudWebService::action
protected function action($action)
{
	$url = $this->getActionURL(array(
		"action" => $action,
		"debug" => ($this->debug? "y": "n"),
	));

	$this->server = new BitrixMainWebHttpClient(array(
		"redirect" => true,
	));
	if ($this->timeout > 0)
		$this->server->setTimeout($this->timeout);

	$strXML = $this->server->get($url);
	if ($strXML === false || !$this->server->getStatus())
	{
		$errors = $this->server->getError();
		throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array(
			"#STATUS#" => $errors? implode(" ", $errors): "-1",
		)), "");
	}

	if ($this->server->getStatus() != 200)
	{
		throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array(
			"#STATUS#" => (string)$this->server->getStatus(),
		)), "");
	}

	$obXML = new CDataXML;
	if (!$obXML->LoadString($strXML))
	{
		throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_XML_PARSE", array(
			"#CODE#" => "1",
		)), "");
	}

	$node = $obXML->SelectNodes("/error/code");
	if (is_object($node))
	{
		$error_code = $node->textContent();
		$message_id = "BCL_CDN_WS_".$error_code;
		/*
		GetMessage("BCL_CDN_WS_LICENSE_EXPIRE");
		GetMessage("BCL_CDN_WS_LICENSE_NOT_FOUND");
		GetMessage("BCL_CDN_WS_QUOTA_EXCEEDED");
		GetMessage("BCL_CDN_WS_CMS_LICENSE_NOT_FOUND");
		GetMessage("BCL_CDN_WS_DOMAIN_NOT_REACHABLE");
		GetMessage("BCL_CDN_WS_LICENSE_DEMO");
		GetMessage("BCL_CDN_WS_LICENSE_NOT_ACTIVE");
		GetMessage("BCL_CDN_WS_NOT_POWERED_BY_BITRIX_CMS");
		GetMessage("BCL_CDN_WS_WRONG_DOMAIN_SPECIFIED");
		*/

		$debug_content = "";
		$node = $obXML->SelectNodes("/error/debug");
		if(is_object($node))
			$debug_content = $node->textContent();

		if (HasMessage($message_id))
		{
			throw new CBitrixCloudException(GetMessage($message_id), $error_code, $debug_content);
		}
		else
		{
			throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array(
				"#STATUS#" => $error_code,
			)), $error_code, $debug_content);
		}
	}

	return $obXML;
}