I can get Instagram photos via public API with the code below (as seen in How to get all images of hashtag in Instagram without API?)
<?php
$baseUrl = 'https://www.instagram.com/explore/tags/girls/?__a=1';
$url = $baseUrl;
while(1) {
$json = json_decode(file_get_contents($url));
print_r($json->tag->media->nodes);
if(!$json->tag->media->page_info->has_next_page) break;
$url = $baseUrl.'&max_id='.$json->tag->media->page_info->end_cursor;
}
However, this code is returned to me only 95 medias, even the user has 1000+ medias (any user)
There is something wrong?
Thanks
Why don't you use instagram-php-scraper?
You can install it via composer
. Create a new dir on your server and type the following on your console:
composer require raiym/instagram-php-scraper
Then simply use:
<?php
require 'vendor/autoload.php';
use InstagramScraper\Instagram;
$medias = Instagram::getMediasByTag('pedro', 200);
header('Content-Type: application/json');
echo json_encode($medias);
Check all the available methods:
https://github.com/postaddictme/instagram-php-scraper/blob/master/README.md