Instagram ?__a=1&max_id=<end_cursor> isn't working for public user feeds

我只是一个虾纸丫 提交于 2019-11-29 03:14:30

问题


I've been using Instagram's undocumented API https://www.instagram.com/<user>/?__a=1 to get a public user feed.

I was also able to get multiple pages via their max_id query parameter like so: 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 had a recent change to their JSON format and I think they might have broken other functionality.

The "end_cursor" is still there but when I use it I just get back the same Instagram posts as if I wasn't using it.

Just to make sure I'm clear, my issue is that the max_id=<end_cursor> doesn't seem to work anymore for a public user feed. I can still get the first 12 posts, but no more after that.

Anyone else seeing this problem?

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


回答1:


04-14-2018 - NO LONGER WORKING - INSTAGRAM DEPRECATED THE '?__a=1' & '?query_id=17888483320059182' - THIS NO LONGER WORKS!

Okay take a look at this for media 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 Media:

['data']['user']['edge_owner_to_timeline_media']['edges']

the 'query_id' is static now so just use: 17888483320059182

'id' is the "instagram user id" so you have to use ?__a=1 to grab ['graphql']['user']['id']

'first' is the number of photos you desire returned. Just use 12 to keep the media return the same.

'after' is the new 'max_id' for use ['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor']

I'll test more and respond later.

Responding Later:

It is believed 'pagination' using ?__a=1 has been deprecated. If true then there is no answer which can solve the op's direct question using ?__a=1 for Instagram pagination.

But the code provided in this answer will provide the pagination of Instagram media which does provide the results the op was seeking.

The answer incorporates the 'instagram graphql api' which is the current api (and not the json ?__a=1 hack) so this answer should provide some stability for now.

As used on my live site:

Grab the id=<instagram_user_id> prior the Instagram media request:

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>




回答2:


You can use this: ?__a=1&page=3



来源:https://stackoverflow.com/questions/49265013/instagram-a-1max-id-end-cursor-isnt-working-for-public-user-feeds

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!