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

Cannot Retrieve All Messages For A Specific Channel #120

Open berkayturanci opened 7 months ago

berkayturanci commented 7 months ago

I am having an issue on retrieving all messages for a channel;

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

On using this;

` private static function updateChannelMessagesFlag(int $spaceId, string $spaceType, string $channelType) { $client = new Client(env("STREAM_CHAT_ACCESS_KEY"), env("STREAM_CHAT_SECRET_ACCESS_KEY"));

    $channelId = self::getChannelId($spaceType, $spaceId, $channelType);

    \Log::info('$channelId is '. $channelId);

    $channel = $client->Channel(
        'team',
        $channelId
    );

    $queryResponse = $channel->query([
        'messages' => [
            'limit' => 300,
            'offset' => 0,
            ]
        ]
    );

    \Log::info('$queryResponse is '. json_encode($queryResponse));

`

I am simply following the quide from here; https://getstream.io/chat/docs/php/channel_pagination/?language=php

My library version is 3.3.0.