Reputation: 3
I am trying to retrieve a message object which contains all sms messages associated with a given account. The code I have started with is copy pasted directly from the usage documentation.
$client = new Services_Twilio($sid, $token);
foreach ($client->account->sms_messages as $message) {
echo $message->body;
echo "<br>";
}
This code does work, in that it will actually retrieve all of the sms messages associated with the account specified with the $sid. However, after the last iteration, it will always throw an uncaught exception:
Fatal error: Uncaught exception 'Services_Twilio_RestException' with message 'AfterSid is required for paging.' in /var/www/includes/twilio-php-library/Services/Twilio.php:298 Stack trace:
0 /var/www/includes/twilio-php-library/Services/Twilio.php(266): Base_Services_Twilio->_processResponse(Array)
1 /var/www/includes/twilio-php-library/Services/Twilio.php(237): Base_Services_Twilio->_makeIdempotentRequest(Array, '/2010-04-01/Acc...', 1)
2 /var/www/includes/twilio-php-library/Services/Twilio/ListResource.php(125): Base_Services_Twilio->retrieveData('/2010-04-01/Acc...', Array)
3 /var/www/includes/twilio-php-library/Services/Twilio/ListResource.php(179): Services_Twilio_ListResource->getPage(8, 50, Array, NULL)
4 [internal function]: Services_Twilio_ListResource->getPageGenerator(8, 50, Array, NULL)
5 /var/www/includes/twilio-php-library/Services/Twilio/AutoPagingIterator.php(104): call_user_func_array(Array, Array)
6 /var/www/includes/twilio-php-library/Services/Twilio/AutoPagingIterator.php(77): Services_Twilio_Au in /var/www/includes/twilio-php-library/Services/Twilio.php on line 298
Upvotes: 0
Views: 157
Reputation: 880
This is a bug in the library related to our deprecation of absolute paging, tracked here https://github.com/twilio/twilio-php/issues/296 . We implemented server-side code today that should mitigate this error from happening for twilio-php.
Upvotes: 1