src/Chatkit.php
public function getRoomMessages($options)
    {
        if (!isset($options['room_id'])) {
            throw new MissingArgumentException('You must provide the ID of the room to fetch messages from');
        }

        $query_params = [];
        if (!empty($options['initial_id'])) {
            $query_params['initial_id'] = $options['initial_id'];
        }
        if (!empty($options['limit'])) {
            $query_params['limit'] = $options['limit'];
        }
        if (!empty($options['direction'])) {
            $query_params['direction'] = $options['direction'];
        }

        $room_id = rawurlencode($options['room_id']);

        return $this->apiRequestV2([
            'method' => 'GET',
            'path' => "/rooms/$room_id/messages",
            'jwt' => $this->getServerToken()['token'],
            'query' => $query_params
        ]);
    }
public function getRoomMessages($options)
    {
        if (!isset($options['room_id'])) {
            throw new MissingArgumentException('You must provide the ID of the room to fetch messages from');
        }

        $query_params = [];
        if (!empty($options['initial_id'])) {
            $query_params['initial_id'] = $options['initial_id'];
        }
        if (!empty($options['limit'])) {
            $query_params['limit'] = $options['limit'];
        }
        if (!empty($options['direction'])) {
            $query_params['direction'] = $options['direction'];
        }

        $room_id = rawurlencode($options['room_id']);

        return $this->apiRequestV2([
            'method' => 'GET',
            'path' => "/rooms/$room_id/messages",
            'jwt' => $this->getServerToken()['token'],
            'query' => $query_params
        ]);
    }
public function getRoomMessages ( $ options ) { if ( ! isset ( $ options [ 'room_id' ] ) ) { throw new MissingArgumentException ( 'You must provide the ID of the room to fetch messages from' ) ; } $ query_params = [ ] ; if ( ! empty ( $ options [ 'initial_id' ] ) ) { $ query_params [ 'initial_id' ] = $ options [ 'initial_id' ] ; } if ( ! empty ( $ options [ 'limit' ] ) ) { $ query_params [ 'limit' ] = $ options [ 'limit' ] ; } if ( ! empty ( $ options [ 'direction' ] ) ) { $ query_params [ 'direction' ] = $ options [ 'direction' ] ; } $ room_id = rawurlencode ( $ options [ 'room_id' ] ) ; return $ this -> apiRequestV2 ( [ 'method' => 'GET' , 'path' => "/rooms/$room_id/messages" , 'jwt' => $ this -> getServerToken ( ) [ 'token' ] , 'query' => $ query_params ] ) ; }
Get messages in a room

@param array $options
[Available Options]
• room_id (string|required): Represents the ID of the room that you want to get the messages for.
• initial_id (integer|optional): Starting ID of the range of messages.
• limit (integer|optional): Number of messages to return
• direction (string|optional): Order of messages - one of newer or older
@return array
@throws ChatkitException or MissingArgumentException
Get messages in a room