我有一个问题。
最近,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/