This article provides a PHP example for quickly parsing data from an API response by applying a paging handler with PHP.
This example doesn’t show HTML paging, rather, automatic canvas through pages to retrieve data.
PHP MaxCDN API example
<?php
require_once 'vendor/autoload.php';
require_once('short/MaxCDN-lib.php');
$params = "";
$api = new MaxCDN("ALIAS", "KEY", "SECRET");
$p = 1;
$i = 0;
while($p != 0){
$params = array("start"=>"2015-07-10 00:00:00", "end"=>"2015-07-12 00:00:00", "limit"=>"1000", "page"=>"$p");
$res1 = $api->get('/v3/reporting/logs.json', $params);
$dat1 = json_decode($res1, true);
if(sizeof($dat1['records']) != 0){
foreach($dat1['records'] as $item){
echo $item['pop'];
}
}
else{
$p = 0;
exit(1);
}
echo "Page " . $p . " done!";
$p = $p + 1;
}
?>
If you have any questions or experience any issues, please reach out to the Support Team, live chat and ticket support are available 24/7.