- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::callChannelPublicList
static function callChannelPublicList($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 = intval($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);
}
$chatId = (int)$params['CALL_CHAT_ID'];
if (!$chatId)
{
throw new BitrixRestRestException("No chat id", "INVALID_FORMAT", CRestServer::STATUS_WRONG_REQUEST);
}
$configParams = Array();
$configParams['TYPE'] = $type;
$configParams['USERS'] = $users;
$configParams['JSON'] = true;
$config = BitrixPullChannel::getPublicIds($configParams);
if ($config === false)
{
throw new BitrixRestRestException("Push & Pull server is not configured", "SERVER_ERROR", CRestServer::STATUS_INTERNAL);
}
return $config;
}