Here is the snippet of twilio doc for php to order messages
<?php
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';
use Twilio\Rest\Client;
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);
$messages = $twilio->conversations->v1->conversations("CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
->messages
->read(["order" => "desc"], 20);
foreach ($messages as $record) {
print($record->sid);
}
Here is my implementation
$messages = $twilio_client->conversations->v1->conversations($conversation_channel_sid)
->messages->read(["order" => "desc"], 20);
but it was not allowed. it ran into following error:
Fatal error: Uncaught TypeError: Argument 1 passed to Twilio\Rest\Conversations\V1\Conversation\MessageList::read() must be of the type int or null, array given, called in D:\xampp\htdocs\teleupachar2.0\P127_TeliUpachar\chat-module\conversation_test.php on line 67 and defined in D:\xampp\htdocs\teleupachar2.0\P127_TeliUpachar\vendor\twilio\sdk\src\Twilio\Rest\Conversations\V1\Conversation\MessageList.php:103 Stack trace: #0 D:\xampp\htdocs\teleupachar2.0\P127_TeliUpachar\chat-module\conversation_test.php(67): Twilio\Rest\Conversations\V1\Conversation\MessageList->read(Array, 20) #1 {main} thrown in D:\xampp\htdocs\teleupachar2.0\P127_TeliUpachar\vendor\twilio\sdk\src\Twilio\Rest\Conversations\V1\Conversation\MessageList.php on line 103
it says it must be of the type int or null. Is there any other ways to filter or sort those messages?
Thank you for your time.