• Модуль: pull
  • Путь к файлу: ~/bitrix/modules/pull/lib/rest.php
  • Класс: BitrixPullRest
  • Вызов: Rest::channelPublicList
static function channelPublicList($params, $n, CRestServer $server)
{
	$params = array_change_key_case($params, CASE_UPPER);

	$type = CPullChannel::TYPE_PRIVATE;
	if ($params['APPLICATION'] === 'Y')
	{
		$clientId = $server->getClientId();
		if (!$clientId)
		{
			throw new BitrixRestRestException("Get application public channel available only for application authorization.", "WRONG_AUTH_TYPE", CRestServer::STATUS_WRONG_REQUEST);
		}
		$type = $clientId;
	}

	$users = Array();
	if (is_string($params['USERS']))
	{
		$params['USERS'] = CUtil::JsObjectToPhp($params['USERS']);
	}
	if (is_array($params['USERS']))
	{
		foreach ($params['USERS'] as $userId)
		{
			$userId = (int)$userId;
			if ($userId > 0)
			{
				$users[$userId] = $userId;
			}
		}
	}

	if (empty($users))
	{
		throw new BitrixRestRestException("A wrong format for the USERS field is passed", "INVALID_FORMAT", CRestServer::STATUS_WRONG_REQUEST);
	}

	$configParams = Array();
	$configParams['TYPE'] = $type;
	$configParams['USERS'] = $users;
	$configParams['JSON'] = true;

	$config = BitrixPullChannel::getPublicIds($configParams);
	if (!$config)
	{
		throw new BitrixRestRestException("Push & Pull server is not configured", "SERVER_ERROR", CRestServer::STATUS_INTERNAL);
	}

	return $config;
}