chriskyfung / AutoFetcher-IG-Stories-to-GDrive

A simple tool to save IG Stories of any user to your Google Drive with just Google Sheets and Apps Script
https://chriskyfung.github.io/AutoFetcher-IG-Stories-to-GDrive/
GNU Affero General Public License v3.0
103 stars 19 forks source link

Instagram changed code? Script no longer working? #11

Closed royjor2016 closed 3 years ago

royjor2016 commented 3 years ago

It seems IG has changed their codes such that this script fails to fetch contents.

Looking at my execution logs, I think it started around noon, 7 Dec, UTC.

I thought it was cookie problem but now I cannot even reproduce the steps to get the "query hash" string.

royjor2016 commented 3 years ago

Running test pipeline:

Dec 8, 2020, 3:59:38 PM Info Dec 08, 2020 Dec 8, 2020, 3:59:39 PM Info {"data":{"reels_media":[]},"status":"ok"} Dec 8, 2020, 3:59:39 PM Info Number of URL(s) from @16278726: 0 Dec 8, 2020, 3:59:39 PM Info {"data":{"reels_media":[]},"status":"ok"} Dec 8, 2020, 3:59:39 PM Info Number of URL(s) from @528817151: 0 Dec 8, 2020, 3:59:39 PM Info {"data":{"reels_media":[]},"status":"ok"} Dec 8, 2020, 3:59:39 PM Info Number of URL(s) from @1112881921: 0 Dec 8, 2020, 3:59:40 PM Info Failed to fetch data from the test accounts!!!

chriskyfung commented 3 years ago

The Endpoint has changed to https://i.instagram.com/api/v1/feed/reels_media/?reel_ids=xxxxxxxxx

But I have no ideas about what the parameter reel_ids stands for.

chriskyfung commented 3 years ago

OK. reel_ids is the Instagram User ID that can be looked up from https://codeofaninja.com/tools/find-instagram-user-id/

But it returns {"message": "useragent mismatch", "status": "fail"} when using a web browser to request the API directly.

There are two new variables, namely, x-ig-app-id and x-ig-www-claim in the header if I view the stories from www.instagram.com. I have to explore whether they are related to the useragent.

chriskyfung commented 3 years ago

@royjor2016

I've updated the code. Could you please test the branch NewEndpoint#11 and see if it works? Thanks!

royjor2016 commented 3 years ago

@chriskyfung TypeError: Cannot read property 'reels_media' of undefined (line 67, file "code")

my line 67 var items = data.reels_media[0].items;

royjor2016 commented 3 years ago

i think it's because JSON changed.

older json data started like this

{"data":{"reels_media":[{"__typename":"GraphReel","id":"xxxxxxx","latest_reel_media":xxxxxxxxxxxx,"can_reply":true,"owner":

now it starts like this

{"reels": {"xxxxxxx": {"id": xxxxxxxxxx, "latest_reel_media":

chriskyfung commented 3 years ago

Please check the following commit.

https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/commit/008ebd6f459245e23935e4a5a7e51490fa35d578

royjor2016 commented 3 years ago

yes it's working smoothly now. thanks a lot for the quick fixes!