Open MGDproductions opened 2 years ago
Same problem. Fix _sharedData = false
works for me too.
Same here. This workaround will let us login, but if we want to use getPhotosByUsername we still need the sharedData value...
i have same issue and changing sharedvalue to false is fixing only login issue. i cant still fetch user profiles and etc
I think instagram moved the object from being loaded with the page to now being lazy loaded, I'm not sure. The object still exists to the browser.
EDIT:
Looks like a problem with x-instagram-gis
being undefined.
for (;;);{"__ar":1,"error":1357004,"errorSummary":"Sorry, something went wrong","errorDescription":"Please try closing and re-opening your browser window.","payload":null,"hsrp":{"hblp":{"consistency":{"rev":1005633177}}},"lid":"7105580147317749642"}
rhx_gis
does not seem to be part of _sharedData
anymore.
@MDproductions-dev
Hello sir,I was also having same issue(_sharedData) and you solved my issue.Thank you so much.You seem expert in this.
Also I was having one more issue.Do you have any solution on challenge urls?
when i am getting followers list sometimes it asks me challenge and then i have to manually enter otp by going to challenge url in browser...
Please help me if you can.I will be very thankfull
This api has been working fine for over a year for me now but since yesterday i have been getting this error:
/home/container/node_modules/instagram-web-api/lib/index.js:109 html => html.split('window._sharedData = ')[1].split(';</script>')[0] ^ TypeError: Cannot read properties of undefined (reading 'split') at /home/container/node_modules/instagram-web-api/lib/index.js:109:55 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Instagram.login (/home/container/node_modules/instagram-web-api/lib/index.js:100:26)
I fixed it myself (somehow) by setting _sharedData to false at line 48 of /lib/index.js I don't know what this does or if it is important to have on so might as well make an issue. Hello sir,I was also having same issue(_sharedData) and you solved my issue.Thank you so much.You seem expert in this. Also I was having one more issue.Do you have any solution on challenge urls? when i am getting followers list sometimes it asks me challenge and then i have to manually enter otp by going to challenge url in browser... Please help me if you can.I will be very thankfull
I think instagram moved the object from being loade
Sir do you have any idea then how can we get likes by photos if shared data is false?
If you don't want to modify the source code, you may call login with {_sharedData: false} as an argument:
const Instagram = require('instagram-web-api') const client = new Instagram({username, password}) await client.login({ username: username, password: password }, { _sharedData: false })
client.login({ username: username, password: password }, { _sharedData: false })
This allows to login but we cant still use functions like GetUserByUsername
This api has been working fine for over a year for me now but since yesterday i have been getting this error:
/home/container/node_modules/instagram-web-api/lib/index.js:109 html => html.split('window._sharedData = ')[1].split(';</script>')[0] ^ TypeError: Cannot read properties of undefined (reading 'split') at /home/container/node_modules/instagram-web-api/lib/index.js:109:55 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Instagram.login (/home/container/node_modules/instagram-web-api/lib/index.js:100:26)
I fixed it myself (somehow) by setting _sharedData to false at line 48 of /lib/index.js I don't know what this does or if it is important to have on so might as well make an issue.
Unfortunately you didn’t fix anything you just do not load data. Instead lib
needs edits accordingly to the new Instagram GraphQL API
format. In fact if you do a View Page Source on a instagram profile and search for _sharedData
you do not get any result.
@jlobos Lobito are you still interested in this library? We need your support to update it
This api has been working fine for over a year for me now but since yesterday i have been getting this error:
/home/container/node_modules/instagram-web-api/lib/index.js:109 html => html.split('window._sharedData = ')[1].split(';</script>')[0] ^ TypeError: Cannot read properties of undefined (reading 'split') at /home/container/node_modules/instagram-web-api/lib/index.js:109:55 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Instagram.login (/home/container/node_modules/instagram-web-api/lib/index.js:100:26)
I fixed it myself (somehow) by setting _sharedData to false at line 48 of /lib/index.js I don't know what this does or if it is important to have on so might as well make an issue.
I tried this approach but sadly its not working, any updates from you @jlobos ?
+1
Same issue...
Still no answer to this?
+1
+1
what do u mean +1?
I think +1 means that person is having the same issue.
+1
I had the same issue, switching it to a personal account (from a business/creator acc) seem to do the trick
I had the same issue, switching it to a personal account (from a business/creator acc) seem to do the trick
mine is personal account but still error
+1
Tried with Creator and Personal account... Always getting the split error mentioned above.
TypeError: Cannot read property 'split' of undefined at ...\node_modules\instagram-web-api\lib\index.js:109:55 at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Instagram.login (...\node_modules\instagram-web-api\lib\index.js:100:26)
at async start (...\src\main.js:20:5)
Setting _sharedData = false
in index.js (line 48) means that my program runs without exception, but still my minimalistic program doesn't fetch my profile:
async function start() { try { await client.login(); const profile = await client.getProfile(); console.log(profile); } catch (e) { console.log("EXCEPTION"); console.log(e); } }
=> Prints undefined for profile Other functions such as .search seem to work, however.
Has anyone found a way out of this situation or any workaround?
Hello,
After trying to fix the issue with _sharedData = false
as suggested I get this error:
$ node index.js
/Users/user/code/instagram-autopost-bot/node_modules/instagram-web-api/lib/index.js:57
value = matches[0].substring(13)
^
TypeError: Cannot read properties of null (reading '0')
at /Users/user/code/instagram-autopost-bot/node_modules/instagram-web-api/lib/index.js:57:22
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Instagram.login (/Users/user/code/instagram-autopost-bot/node_modules/instagram-web-api/lib/index.js:54:5)
Node.js v18.10.0
any idea how to fix ?
+1
seems like instagram changed their code a couple months ago, found this fix on another app though for same issue (no shared data): https://github.com/arc298/instagram-scraper/pull/809
another relevant post: https://github.com/instaloader/instaloader/issues/1553
update: Some data is now located at "https://i.instagram.com/api/v1/users/web_profile_info/?username=myUserName", then the json data is under ['data']['user'] if I am reading that pull request right, however this involves changing the baseUrl to i.instagram.com which breaks everything
also this endpoint fails to load if the useragent is not instagram based-- e.g. "Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Instagram 244.0.0.12.112 (iPhone12,1; iOS 15_5; en_US; en-US; scale=2.00; 828x1792; 383361019)"
update 2: I've gotten past the login, now that just leaves... everything else in the plugin https://github.com/hydrix9/instagram-web-api/blob/master/lib/index.js mainly all the URLs seem to be scrambled this is extremely rough, I apologize for butchering this code
@hydrix9 you are a gem 💎💎💎
I managed to get follow and unfollow working https://github.com/hydrix9/instagram-web-api/blob/master/lib/index.js
it seems like all the /web/ urls are now at i.instagram.com/api/v1/web/ approve, ignore, block, unblock, like, unlike, save, unsave, and search might also be working but I haven't tested it yet
In my code I removed _getGis and _getSharedData since those were only being used for getUserByUsername. In my code getUserByUsername now returns the results from https://i.instagram.com/api/v1/users/web_profile_info/?username=myUserName
I'm working on uploadPhoto, I had to add the followeAllRedirects=true option to prevent a 302 error (not sure where it redirects) also the response seemed to be gzipped, which was solved by adding the gzip=true option gzip might be needed to be turned off if it does start returning json right now its returning html of a blank page instead of json containing the upload_id we need to do part 2 in uploadPhoto however on the web interface, when doing the request it returns the json as expected not sure where to go from here, I tried adding 'form' data like you see in the POST request on the web interface when posting an image, but that caused it to start giving socket hang up error instead
I'll have more time to work on this in a couple days, if anyone wants to fix something that's giving a 404 page on request try adding baseUrl: baseUrlApi to the request options to use the i.instagram.com/web/api/ base url instead in my code. I was able to find which url to use by going on the web interface and performing an action and watching the post requests with ctrl-shift-i -> networking on firefox
update: I think I found the correct url now for uploadPhoto at "https://i.instagram.com/rupload_igphoto/fb_uploader_{myId}" instead of "instagram.com/ruploadigphoto/{myDate}_0\{myId}" and it's giving a '403 login required' instead of the error above, so looks promising
I got uploadPhoto working
https://github.com/hydrix9/instagram-web-api/blob/master/lib/index.js
bad news, https://i.instagram.com/rupload_igphoto/fb_uploader_{myId} takes a sessionid cookie now or it will redirect you to a login page, which explains why it was giving the 302 error with a gzipped html page before
worse news, its generated on the client on login and I'm not sure how to reverse engineer it
I managed to find the sessionid code here: https://static.cdninstagram.com/rsrc.php/v3iF2k4/y-/l/en_US/dY3zq_4wAbs.js?_nc_x=Ij3Wp8lg5Kz
it has a function called getSessionID which returns
this.getTabId() + ":" + this.getPageId() + ":" + this.getTransitionId() + "-" + this.getActivityId()
I gave a shot at generating it with getNewSessionId in my code but it didn't work for me, seems to be a little more than random numbers
there's another cookie generated on client called x-ig-www-claim but I don't think we need it
my hackish fix right now is to simply login on instagram.com and find the sessionid under ctrl-shift-i (on firefox) -> storage -> cookies -> instagram.com -> session id and copy that, the cookie should be good for a year at least
anyways this is way out of scope of the original error, but I got the three major functions I needed working and I wish you luck on fixing the rest of the functions
For everyone who looking for solution: Based on this youtube desc: https://www.youtube.com/watch?v=XzyYi_yv86A
www.facebook.com1007698095-7245399117884480117
for (;;);{"__ar":1,"error":1357004,"errorSummary":"Sorry, something went wrong","errorDescription":"Please try closing and re-opening your browser window.","payload":null,"hsrp":{"hblp":{"consistency":{"rev":1007698095}}},"lid":"7245399117884480117"}
try replace your lib/index,js with this files :
https://github.com/amamenko/inky-doodle/blob/master/instagram-web-api/index.js
try replace your lib/index,js with this files :
https://github.com/amamenko/inky-doodle/blob/master/instagram-web-api/index.js
after running for call function getPhotosByUsername
so result for this :
{
user: {
edge_owner_to_timeline_media: { count: 631, page_info: [Object], edges: [Array] }
}
}
try replace your lib/index,js with this files :
https://github.com/amamenko/inky-doodle/blob/master/instagram-web-api/index.js
I'm unable to login. 403 error
This api has been working fine for over a year for me now but since yesterday i have been getting this error:
I fixed it myself (somehow) by setting _sharedData to false at line 48 of /lib/index.js I don't know what this does or if it is important to have on so might as well make an issue.