I am using the Twilio SDK to make REST requests to fetch the calls made during the last day and the amount of calls is bigger than the total amount of calls on my account. It just keeps running indefinitely.
I did make only one request to the trillionth page and I receive records.
<?php
$newClient = new \Twilio\Rest\Client(
Config_Twilio::ACCOUNT_SID,
Config_Twilio::AUTH_TOKEN
);
$lastNDays = 1;
$params = [
'startTime' => date('Y-m-d', strtotime('-' . $lastNDays . ' days'))
];
#some code to make a first request here...
.
.
.
if($content['next_page_uri']) {
do {
$params['Page'] = $content['page']+1;
try {
$response = $newClient->request(
"GET",
Config_Twilio::DOMAIN_URL . "/" . Config_Twilio::API_VERSION . "/Accounts/" .
Config_Twilio::ACCOUNT_SID . "/Calls.json",
$params
);
$content = $response->getContent();
if (is_array($content['calls'])) {
$callSets = array_merge($content['calls']);
}
} catch (\Throwable $th) {
//throw $th;
}
} while ($content['next_page_uri'] !== null);
}
How can I obtain all the records avoiding this infinite loop?