这是 twilio doc 的片段,用于 php 来订购消息
<?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);
}
这是我的实现
$messages = $twilio_client->conversations->v1->conversations($conversation_channel_sid)
->messages->read(["order" => "desc"], 20);
但这是不允许的。它遇到了以下错误:
致命错误:未捕获的 TypeError:传递给 Twilio\Rest\Conversations\V1\Conversation\MessageList::read() 的参数 1 必须是 int 或 null 类型,给定数组,在 D:\xampp\htdocs\teleupachar2.0 中调用\P127_TeliUpachar\chat-module\conversation_test.php 在第 67 行并在 D:\xampp\htdocs\teleupachar2.0\P127_TeliUpachar\vendor\twilio\sdk\src\Twilio\Rest\Conversations\V1\Conversation\MessageList.php 中定义:103 堆栈跟踪:#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} 在第 103 行的 D:\xampp\htdocs\teleupachar2.0\P127_TeliUpachar\vendor\twilio\sdk\src\Twilio\Rest\Conversations\V1\Conversation\MessageList.php 中抛出
它说它必须是 int 或 null 类型。还有其他方法可以过滤或排序这些消息吗?
感谢您的时间。