TWILIO-API:列出数据范围内的记录

时间:2016-12-08 13:58:42

标签: twilio twilio-api

Twilio网站上提供的这个例子不起作用:

$records = $client->recordings->read(0, 10, array(
"datecreatedBefore" => "2016-12-04",
"datecreatedAfter" => "2016-12-01"    
));

它仍会显示此范围之外的录音。知道如何按日期过滤吗?

谢谢!

1 个答案:

答案 0 :(得分:2)

Twilio developer evangelist here.

It looks like there maybe a mistake in translating from the v4 Twilio PHP library to the v5 library. Previously, the getIterator method took a page and page size argument before the remaining options for filtering.

$recordings = $client->account->recordings->getIterator(0, 50, array(
    "DateCreated<" => "2016-10-15",
    "DateCreated>" => "2016-10-12"
))

With the v5 library, read takes the array of options first, followed by a limit and then page size. So, to use the iterator with a limit of 10 you need to call it like this:

$recordings = $client->recordings->read(array(
    "datecreatedBefore" => "2016-12-04",
    "datecreatedAfter" => "2016-12-01" 
), 10, 10);

Let me know if this helps at all.