GetStream / stream-chat-php

Stream Chat official PHP API Client
https://getstream.io/chat/
BSD 3-Clause "New" or "Revised" License
30 stars 9 forks source link

Query all members of channel without any conditions #27

Closed SviatKuzma closed 3 years ago

SviatKuzma commented 3 years ago

$client->Channel($params['type'], $id)->queryMembers([]); - returns me

"message": "{\"code\":4,\"message\":\"QueryMembers failed with error: \\"expected object for field \\"filter_conditions\\" but got array\\"\",\"StatusCode\":400,\"duration\":\"0.00ms\",\"more_info\":\"https://getstream.io/chat/docs/api_errors_response\"}",

So I want to know how I should pass an object into this method?

gz#7604

shodgetts commented 3 years ago

Agent comment from Seetha in Zendesk ticket #7604:

Hi

Thanks for reaching out to us. To query all members of channel without any condition, please pass an empty object like this - $client->Channel($params['type'], $id)->queryMembers({});

Cheers Seetha

SviatKuzma commented 3 years ago

Agent comment from Seetha in Zendesk ticket #7604:

Hi

Thanks for reaching out to us. To query all members of channel without any condition, please pass an empty object like this - $client->Channel($params['type'], $id)->queryMembers({});

Cheers Seetha

In Controller if (isset($client, $params['type'])) { return $client->Channel($params['type'], $id)->queryMembers({}); }

In response { "success": false, "data": { "name": "Exception", "message": "syntax error, unexpected '{'", "code": 0, "type": "ParseError", "file": "/app/.../GetStreamController.php", "line": 208, "stack-trace": [ "#0 [internal function]: yii\BaseYii::autoload('frontend\\module...')", "#1 [internal function]: spl_autoload_call('frontend\\module...')", "#2 /app/phpApp/vendor/yiisoft/yii2/base/Module.php(637): class_exists('frontend\\module...')", "#3 /app/phpApp/vendor/yiisoft/yii2/base/Module.php(596): yii\base\Module->createControllerByID('chat/get-stream')", "#4 /app/phpApp/vendor/yiisoft/yii2/base/Module.php(588): yii\base\Module->createController('get-members')", "#5 /app/phpApp/vendor/yiisoft/yii2/base/Module.php(522): yii\base\Module->createController('chat/get-stream...')", "#6 /app/phpApp/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('v1/chat/get-str...', Array)", "#7 /app/phpApp/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))", "#8 /app/phpApp/frontend/web/index.php(19): yii\base\Application->run()", "#9 {main}" ] } }

shodgetts commented 3 years ago

One last thing before we escalate this issue, can you try with $client->Channel($params['type'], $id)->queryMembers();

SviatKuzma commented 3 years ago
Screenshot 2020-12-09 at 17 28 16

{ "success": false, "data": { "name": "Exception", "message": "Too few arguments to function GetStream\StreamChat\Channel::queryMembers(), 0 passed in /var/.../GetStreamController.php on line 94 and at least 1 expected", "code": 0, "type": "ArgumentCountError", "file": "/var/.../StreamChat/Channel.php", "line": 192, "stack-trace": [ "#0 /var/.../GetStreamController.php(94): GetStream\StreamChat\Channel->queryMembers()", "#1 [internal function]: ...\GetStreamController->actionGetUserToken()", "#2 /var/.../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)", "#3 /var/.../vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)", "#4 /var/.../vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('get-user-token', Array)", "#5 /var/.../vendor/yiisoft/yii2/web/Application.php(104): yii\base\Module->runAction('v1/chat/get-str...', Array)", "#6 /var/.../vendor/yiisoft/yii2/base/Application.php(392): yii\web\Application->handleRequest(Object(yii\web\Request))", "#7 /var/.../web/index.php(19): yii\base\Application->run()", "#8 {main}" ] } }

ferhatelmas commented 3 years ago

@SviatKuzma $client->Channel($params['type'], $id)->queryMembers(); works now as of https://github.com/GetStream/stream-chat-php/releases/tag/1.1.9