I have the following code - I would like to keep filling the array with URL
https://api.dailymotion.com/user/cricshare/videos?page=1&limit=100 until JSON response"has_more":false
For example:
First URL:
https://api.dailymotion.com/user/cricshare/videos?page=1&limit=100 => "has_more":true
put URL in array and get next URL
Second URL:
https://api.dailymotion.com/user/cricshare/videos?page=2&limit=100 => "has_more":true
put URL in array and get next URL
Third URL:
https://api.dailymotion.com/user/cricshare/videos?page=2&limit=100 => "has_more":false
don't get any URL finish the array as "has_more":false
<?php
error_reporting(E_ALL);
$urls = array(
'https://api.dailymotion.com/user/cricshare/videos?page=1&limit=100',
'https://api.dailymotion.com/user/cricshare/videos?page=2&limit=100',
'https://api.dailymotion.com/user/cricshare/videos?page=3&limit=100'
);
$sets = array();
foreach ($urls as $url) {
$json = file_get_contents($url);
$data = json_decode($json);
$sets[] = $data;
}
$new = json_encode($sets, JSON_PRETTY_PRINT);
echo '<pre>';
echo $new;
?>
Open in new window
This returns only the "lists" from each of the URLs. The return value is one long array that merges the lists.
Open in new window