PHP-Instagram-Grabber
PHP-Instagram-Grabber copied to clipboard
Instagram changed
Hi, it seems like that Instagram has been changed again. The /query/ endpoint does not work since today.
yes, same problem here since today
Does somebody know if the Endpoint is completely gone or still works with login? Where was the query Endpoint used on the website? When I look through the website, https://www.instagram.com/graphql/query/ is used. Maybe they replaced them?
seems like old method working again without authorization u can get json data from https://www.instagram.com/username/?__a=1 or https://www.instagram.com/explore/tag/?__a=1 and paginate via end_cursor
$baseUrl = 'https://www.instagram.com/explore/tags/tag/?__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;
}
Yes, but the query parameter is much more flexible than that.
Anyone figured out what's going on? I can't see any documented changes on https://www.instagram.com/developer/changelog/
And I can't figure out end-points in previous comments :|
They don't need to document it as it's not an official API endpoint or something...
Ok sorry, I have a hard time following what's happening and why it's not working anymore. Any suggestion on how to fix it?
Would be great to know if a fix is in the works?
Hello, have a solution?
If any got a solution for this, please make a PR :)
What @ethereali wrote actually gives temporary solution. It's not the same as query parameter result, but it gives essential data for fetching hashtag. It lacks of owner details. But you can get them from https://www.instagram.com/p/blabla/?__a=1
Awesome 🗡
header('Content-Type: application/json');
$baseUrl = 'https://www.instagram.com/explore/tags/crossfitconcordia/?__a=1';
$url = $baseUrl;
$json = json_decode(file_get_contents($url));
$jsonImagens = "[";
$total = count($json->tag->media->nodes);
$soma = 0;
foreach ($json->tag->media->nodes as $key => $value) {
$soma++;
$jsonImagens .= '{"display_src":"'.$value->display_src.'","code": "'.$value->code.'"}';
if($soma != $total){
$jsonImagens .= ",";
}
}
$jsonImagens .= "]";
print_r(($jsonImagens));
Is there any update. Has anyone been able to find a solution?
HI everyone,
Now possilbe request with using https://www.instagram.com/graphql/query/
endpoint
Because https://www.instagram.com/explore/tag/?__a=1
for me does not work with "end_cursor"
Example: https://www.instagram.com/graphql/query/?query_id=17882293912014529&tag_name=best_photo&first=9&after=J0HWVISlQAAAF0HWVCuAwAAAFjwA
The question is how query_id
is generated.
Current value "17882293912014529" work at least 10 days.
But it can be changed at any moment for another value.
first
- count
after
- end_cursor
Just returned data have some chnaged fields names, os I used "normalize" function:
public static function _normalizeEdgeEntries($nodes)
{
$normalized = array();
foreach ($nodes as $node) {
$normalized[] = (object)array(
"id" => $node->node->id,
"owner" => $node->node->owner,
"code" => $node->node->shortcode,
"date" => $node->node->taken_at_timestamp,
"is_video" => $node->node->is_video,
"thumbnail_src" => $node->node->thumbnail_src,
"display_src" => $node->node->display_url,
"dimensions" => $node->node->dimensions,
"comments" => $node->node->edge_media_to_comment,
"likes" => $node->node->edge_liked_by,
"caption" => isset($node->node->edge_media_to_caption->edges[0]->node->text) ? $node->node->edge_media_to_caption->edges[0]->node->text : '',
);
}
// "comments_disabled": false,
// "id": "1545479499906608694",
// "edge_media_to_caption": {
// "edges": [{
// "node": {
// "text": "\ud83d\udd32\nIndigo Slam; Central Park; Sydney; Australia\nby William Smart Design Studio\n.\n.\n.\n#architecture #architect #architecture_lover #archilover #day_photo #best_photo #art #arch #design #designer #modernism #modern_architecture #archido #idea #live #better_world #better_life #luxury #construct #volume #building #build #old #old_modernism #black\u0026white #B\u0026W"
// }
// }]
// },
// "shortcode": "BVypWq3lO42",
// "edge_media_to_comment": {
// "count": 0
// },
// "taken_at_timestamp": 1498455534,
// "dimensions": {
// "height": 640,
// "width": 640
// },
// "display_url": "https://scontent-ams3-1.cdninstagram.com/t51.2885-15/e35/19425294_108746296416893_3924234936009097216_n.jpg",
// "edge_liked_by": {
// "count": 109
// },
// "owner": {
// "id": "3193971795"
// },
// "thumbnail_src": "https://scontent-ams3-1.cdninstagram.com/t51.2885-15/e35/19425294_108746296416893_3924234936009097216_n.jpg",
// "is_video": false
return $normalized;
}
The fix from @shelontwo works great for me
The advantage of the plugin before, was the fact it could iterate through pages. The workaround in the thread only fetches the first page?
Someone does know how to get username from id ?
when i run this link "https://www.instagram.com/?__a=1" it returns {"graphql":null} anyone knows why this happens?
@alyysaafan should be like https://www.instagram.com/explore/tags/330ci/?__a=1
@rickymatthews use it when it is like that "https://www.instagram.com/?__a=1" it should returns recent feed, i used it on many accounts worked fine but when i use it on my account it returns {"graphql":null}
is your account private? @alyysaafan
@rickymatthews no
well, then use https://www.instagram.com/your_account/?__a=1 no?