如何在没有API的情况下获得Instagram订阅源?

时间:2016-06-03 01:06:56

标签: json api curl cookies instagram

我编写自己的应用程序,必须在网格中显示我的订阅Feed照片,因为我没有时间在我的Feed上刷一张经典的大照片。早些时候我使用了自己的应用程序,它使用了API,但众所周知,Instagram关闭了应用程序的API,这些应用程序是在sandmode中。

所以现在我写了一个新的应用程序,用cURL和cookies获取照片(这是我自己的应用程序,所以我使用自己的cookie)。

我需要完全订阅Feed,而不是我自己的Feed。

所以,一开始我只是收到主页面的内容(instagram.com)(因为我有cookie,所以我可以让我的feed只是访问Instagram主页)并解析得到他们的JSON数据,这是原始的。但问题是,我只能以这种方式获得前24张照片,但是有一个类似于next_id的东西,或者像这样的东西,它可以使用自己的Feed吗?

https://www.instagram.com/instagram/?max_id=1261078189229875262

但最好的方法是立刻获得一个JSON,没有必要解析html,看起来像:

https://www.instagram.com/instagram/media/?max_id=1261078189229875262

非常感谢你的回答。

1 个答案:

答案 0 :(得分:1)

在Chrome中打开您的Instagram Feed。打开开发工具到“网络”选项卡。将Feed滚动到底部,并在将Feed滚动到底部时检查他们进行的API调用。

根据我的收集情况,他们会将所有Cookie以及2个参数$q$ref发布到https://www.instagram.com/query/

$ref = 'feed::show';
$q = 'ig_me(){feed{media.after(***$end_cursor***,***count***){nodes{id,caption,code,comments.last(4){count,nodes{id,created_at,text,user{id,profile_pic_url,username}},page_info},date,dimensions{height,width},display_src,is_video,likes{count,nodes{user{id,profile_pic_url,username}},viewer_has_liked},location{id,has_public_page,name},owner{id,blocked_by_viewer,followed_by_viewer,full_name,has_blocked_viewer,is_private,profile_pic_url,requested_by_viewer,username},usertags{nodes{user{username},x,y}},video_url,video_views},page_info}},id,profile_pic_url,username}';

在ig_me()函数中有一个$end_cursor parm。通过检查window._sharedData对象的页面可以找到这一点。

window._sharedData内,您可以在end_cursor

找到entry_data.FeedPage[0].feed.media.page_info.end_cursor

还有一个$count设置为12,可以获取多少图像/视频(我没有玩过你可以在这里添加的数量)。

此来电的回复将为您提供新的$end_cursor feed.media.end_cursor,您可以在下次通话时使用。{/ p> 祝你好运!