2016-12-12 49 views
0

我遇到問題。嘗試通過API獲取Instagram故事時的問題

最近,Instagram發佈了一個名爲「Instagram故事」的新功能,它似乎允許您獲取每個用戶的故事。

在此描述:

塊引用 要獲得故事的列表,只需做一個GET請求: https://i.instagram.com/api/v1/feed/reels_tray/ 此端點返回與「托盤」或酒吧在相關聯的所有數據與您所有朋友的個人資料照片一起顯示在您的Feed中。 現在,認證呢?這就是那些甜餅乾進來的地方。Instagram的桌面網站會保存你的會話cookie以驗證你的請求。 大段引用

但每次我嘗試發送會話cookie(我用我自己的Instagram帳戶的餅乾)的Instagram返回我響應「Login_Required」。不管我如何嘗試。

例如,我試圖將這些cookie添加到標題並使用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); 

有沒有人知道 - 如何處理這種問題?

回答

0

你忘了設定你的cookieStore

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