Instagram ?__a=1&max_id=<end_cursor> 不适用于 public 用户供稿

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

我一直在使用 Instagram 的未记录 API https://www.instagram.com/<user>/?__a=1 来获取 public 用户供稿。

我还能够通过他们的 max_id 查询参数获取多个页面,如下所示: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

(是的,"has_next_page" 是正确的)

他们最近更改了 JSON 格式,我认为他们可能破坏了其他功能。

"end_cursor" 仍然存在,但当我使用它时,我只是返回相同的 Instagram 帖子,就好像我没有使用它一样。

为了确保我清楚,我的问题是 max_id=<end_cursor> 似乎不再适用于 public 用户供稿。我仍然可以获得前 12 个帖子,但之后就没有了。

还有其他人看到这个问题吗?

这是我的意思的 JSFiddle 示例: https://jsfiddle.net/LLsg91ja/33/

04-14-2018 - 不再工作 - INSTAGRAM 已弃用 '?__a=1' 和 '?query_id=17888483320059182' - 这不再工作!

好的,看看这个媒体分页:

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

这个returns:

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

和媒体:

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

'query_id' 现在是静态的,所以只需使用:17888483320059182

'id' 是 "instagram user id" 所以你必须使用 ?__a=1 来获取 ['graphql']['user']['id']

'first' 是您想要 return 编辑的照片数量。只需使用 12 即可保持媒体 return 相同。

'after' 是新的 'max_id' 用于 ['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor']

我再测试一下再回复。

稍后回复:

据信 'pagination' 使用 ?__a=1 已被弃用。如果为真,则没有答案可以使用 ?__a=1 用于 Instagram 分页来解决操作员的直接问题。

但是此答案中提供的代码将提供 Instagram 媒体的分页,它确实提供了 op 正在寻找的结果。

答案包含 'instagram graphql api',这是当前的 api(而不是 json ?__a=1 hack)所以这个答案现在应该提供一些稳定性。

在我的实时网站上使用:

在 Instagram 媒体请求之前获取 id=<instagram_user_id>

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>

你可以使用这个:?__a=1&page=3