The Twilio API docs describe retrieving all messages or a particular message in PHP like bellow:
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
// Loop over the list of messages and echo a property for each one
foreach ($client->messages->read() as $message) {
echo $message->body;
}
But fetching all messages with a single call and bringing it to the front end leads to heavy load on my application. So is there any way to implement pagination in a nice way to put latest 50 messages upon clicking next button next 50 and so on?