Instagram? __ a = 1 & max_id = <end_cursor> does not work for public user feeds

I used the Instocument undocumented API https://www.instagram.com/<user>/?__a=1 to get the user's public feed.

I also managed to get several pages through their max_id request max_id , for example: https://www.instagram.com/<user>/?__a=1&max_id=<end_cursor>

 end_cursor = json_response.graphql.user.edge_owner_to_timeline_media.page_info.end_cursor 

(yes, "has_next_page" is true)

They have recently changed the JSON format, and I think they could violate other functions.

"end_cursor" still exists, but when I use it, I just return the same Instagram posts as if I weren't using it.

Just to make sure I understand, my problem is that max_id=<end_cursor> no longer works for a public user feed. I can still get the first 12 messages, but nothing more.

Does anyone else see this problem?

here's a JSFiddle example, what I mean: https://jsfiddle.net/LLsg91ja/33/

+5
source share
2 answers

Take a good look at this for pagination:

https://instagram.com/graphql/query/?query_id=17888483320059182&id=<user_id>&first=12&after=<end_cursor>

This returns:

['data'] ['user'] ['edge_owner_to_timeline_media'] ['page_info'] ['end_cursor']

And carriers:

['data'] ['user'] ['edge_owner_to_timeline_media'] ['edge']

'query_id' is static, so just use: 17888483320059182

'id' is the instagram user id, so you should use ?__a=1 to capture ['graphql'] ['user'] ['id']

'first' is the number of photos returned. Just use 12 to maintain feedback.

'after' - the new 'max_id' to use ['data'] ['user'] ['edge_owner_to_timeline_media'] ['page_info'] ['end_cursor']

I will test more and respond later.

Responding later:

It is believed that pagination using ?__a=1 is deprecated. If true, then there is no answer that can solve the direct request using ?__a=1 to paginate Instagram pages.

But the code provided in this answer will provide pagination for Instagram media that provide op search results.

The answer includes an "instagram graphql api" which is the current api (and not json ?__a=1 hack), so this answer should provide some stability at the moment.

How is used on my site:

Take id=<instagram_user_id> before requesting to print on Instagram:

profile = https://www.instagram.com/<instagram_username>/?__a=1

media = https://instagram.com/graphql/query/?query_id=17888483320059182&id=<profile['graphql']['user']['id']>&first=12&after=<end_cursor>

+9
source

Can you use this :? __ a = 1 & page = 3

+1
source

Source: https://habr.com/ru/post/1275878/


All Articles