• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/classes/general/rest.php
  • Класс: CRestServer
  • Вызов: CRestServer::requestConfirmation
public function requestConfirmation($userList, $message)
{
	if($message == '')
	{
		throw new ArgumentNullException('message');
	}

	if(!is_array($userList) && intval($userList) > 0)
	{
		$userList = array($userList);
	}

	if(count($userList) <= 0)
	{
		throw new ArgumentNullException('userList');
	}

	if(!$this->getClientId())
	{
		throw new AccessException('Application context required');
	}

	if(
		!isset($this->authData['parameters'])
		|| !isset($this->authData['parameters']['notify_allow'])
		|| !array_key_exists($this->method, $this->authData['parameters']['notify_allow'])
	)
	{
		$notify = new BitrixRestNotify(BitrixRestNotify::NOTIFY_BOT, $userList);
		$notify->send($this->getClientId(), $this->authData['access_token'], $this->method, $message);

		$this->authData['parameters']['notify_allow'][$this->method] = 0;

		if($this->authData['parameters_callback'] && is_callable($this->authData['parameters_callback']))
		{
			call_user_func_array($this->authData['parameters_callback'], array($this->authData));
		}
	}

	if($this->authData['parameters']['notify_allow'][$this->method] === 0)
	{
		throw new RestException('Waiting for confirmation', 'METHOD_CONFIRM_WAITING', static::STATUS_UNAUTHORIZED);
	}
	elseif($this->authData['parameters']['notify_allow'][$this->method] < 0)
	{
		throw new RestException('Method call denied', 'METHOD_CONFIRM_DENIED', static::STATUS_FORBIDDEN);
	}

	return true;
}