- file_get_contents: documentation ( source)
- json_decode: documentation ( source)
- array_merge: documentation ( source)
<?php
$limite = 100;
$tag = 'lembrardesercrianca';
// Client id
$client_id = "60d01f1357c24a5aab29133e8f91de2a";
// Api
$api = "https://api.instagram.com/v1/tags/$tag/media/recent?client_id=$client_id&count=$limite";
//populares
//$api = "https://api.instagram.com/v1/tags/$tag/media/popular?client_id=$client_id&count=$limite";
// Contents
$contents = file_get_contents($api);
// Json
$json = json_decode($contents, true);
// Find in the next 5 pages (limited for 20 results by page)
for ($i = 0; $i < 5; $i++) {
if($json['pagination']['next_url']){
$nextLink = $json['pagination']['next_url'];
$contents = file_get_contents($nextLink);
$json2 = json_decode($contents, true);
// Add the data
$combinedData = array_merge($json['data'], $json2['data']);
}
}
return $combinedData;
?>