java - 尝试通过 API 获取 Instagram 故事时出现问题

标签 java instagram

我有一个问题。

最近,Instagram 推出了一项名为“Instagram Stories”的新功能,似乎可以让你获取每个用户的故事。

这里有描述:

Blockquote To get the list of Stories, simply make a GET request to: https://i.instagram.com/api/v1/feed/reels_tray/ This endpoint returns all the data associated with the “tray” or bar at the top of your feed with all your friends’ profile pictures. Now, what about authentication? This is where those sweet cookies 🍪🍪🍪 come in. Instagram’s desktop website saves cookies about your session to authenticate your requests. Blockquote

但每次我尝试发送 session cookie(我使用的是我自己的 Instagram 帐户的 cookie)时,Instagram 都会向我返回“Login_Required”响应。不管我怎么努力。

例如我尝试将这些 cookie 添加到 header 并使用 Java 发出请求:

CookieStore cookieStore = new BasicCookieStore();
HttpClient client = HttpClientBuilder.create().build();

HttpGet get = new HttpGet("https://i.instagram.com/api/v1/feed/reels_tray/");

get.setHeader("Content-Type", "application/x-www-form-urlencoded");
BasicClientCookie cookie = new BasicClientCookie("ds_user_id", "6576149574");
BasicClientCookie cookie2 = new BasicClientCookie("sessionid", "IGSC484a13346681fb6ee5ba32114e491c6efc66015f812908156b1c1334cb49387d");
cookieStore.addCookie(cookie);
cookieStore.addCookie(cookie2);
HttpResponse response = client.execute(get);

有人知道如何处理此类问题吗?

最佳答案

您是否忘记设置 cookieStore

HttpClient client = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();

关于java - 尝试通过 API 获取 Instagram 故事时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41103317/

相关文章:

java - 闹钟管理器在一周中的某一天设置闹钟

java - 通过 HttpGet 从 Web 服务读取 char[] — 奇怪的行为

java - 为什么在 jsp 中使用 if 语句会出现此错误?

php - 使用 curl PHP 登录 Instagram

java.io.FileNotFoundException : D:\Servers\apache-tomcat-7. 0.27\webapps\acct\accesscarddata (访问被拒绝)

php - 从 instagram 保存 instagram 高分辨率图像

android - 来自 Android 的 Instagram 在特定用户上打开并为上传的图像添加标题

linux - 如何使用 wget 自动下载 Instagram 页面

flutter : Not getting code while Instagram login (Instagram login not working)

java - For 循环检查玩家位置