PHP-Instagram-Grabber icon indicating copy to clipboard operation
PHP-Instagram-Grabber copied to clipboard

Instagram changed

Open ncmsalzburg opened this issue 7 years ago • 23 comments

Hi, it seems like that Instagram has been changed again. The /query/ endpoint does not work since today.

ncmsalzburg avatar Jun 13 '17 10:06 ncmsalzburg

yes, same problem here since today

sabilawijaya avatar Jun 13 '17 16:06 sabilawijaya

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?

maddo7 avatar Jun 13 '17 17:06 maddo7

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;
}

ethereali avatar Jun 14 '17 07:06 ethereali

Yes, but the query parameter is much more flexible than that.

maddo7 avatar Jun 14 '17 09:06 maddo7

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 :|

slackday avatar Jun 15 '17 10:06 slackday

They don't need to document it as it's not an official API endpoint or something...

paha77 avatar Jun 15 '17 11:06 paha77

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?

slackday avatar Jun 15 '17 11:06 slackday

Would be great to know if a fix is in the works?

SEMNON avatar Jun 18 '17 02:06 SEMNON

Hello, have a solution?

shelontwo avatar Jun 20 '17 19:06 shelontwo

If any got a solution for this, please make a PR :)

Bolandish avatar Jun 21 '17 07:06 Bolandish

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

mbilgidhis avatar Jun 21 '17 12:06 mbilgidhis

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));

shelontwo avatar Jun 21 '17 14:06 shelontwo

Is there any update. Has anyone been able to find a solution?

scottyzen avatar Jun 27 '17 20:06 scottyzen

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;
    }

max-kk avatar Jun 28 '17 11:06 max-kk

The fix from @shelontwo works great for me

RD1612 avatar Jun 28 '17 11:06 RD1612

The advantage of the plugin before, was the fact it could iterate through pages. The workaround in the thread only fetches the first page?

rickymatthews avatar Aug 14 '17 10:08 rickymatthews

Someone does know how to get username from id ?

freddurst1805 avatar Feb 02 '18 12:02 freddurst1805

when i run this link "https://www.instagram.com/?__a=1" it returns {"graphql":null} anyone knows why this happens?

alyysaafan avatar Feb 22 '18 13:02 alyysaafan

@alyysaafan should be like https://www.instagram.com/explore/tags/330ci/?__a=1

rickymatthews avatar Feb 22 '18 13:02 rickymatthews

@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}

alyysaafan avatar Feb 22 '18 13:02 alyysaafan

is your account private? @alyysaafan

rickymatthews avatar Feb 22 '18 14:02 rickymatthews

@rickymatthews no

alyysaafan avatar Feb 22 '18 15:02 alyysaafan

well, then use https://www.instagram.com/your_account/?__a=1 no?

verybigelephants avatar Feb 28 '18 14:02 verybigelephants