instagram-php-scraper: Getting error 400 Bad request
It was working very well till later today I started to get this error:
Fatal error: Uncaught InstagramScraper\Exception\InstagramAuthException: Response code is 400. Body: Bad request Something went wrong. Please report issue. in /home2/hamzadiaz/public_html/instagram/vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php:1664 Stack trace: #0 /home2/hamzadiaz/public_html/instagram/profile.php(26): InstagramScraper\Instagram->login() #1 {main} thrown in /home2/hamzadiaz/public_html/instagram/vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php on line 1664
I tried using different Instagram account for login but getting same error. Here is what line 1664 Instagram.php of code has:
} elseif ((is_string($response->code) || is_numeric($response->code)) && is_string($response->body)) {
throw new InstagramAuthException('Response code is ' . $response->code . '. Body: ' . $response->body . ' Something went wrong. Please report issue.', $response->code);
}
Can’t figure out how to get it fixed, Maybe Instagram made some update?
Thanks in advance
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 43 (5 by maintainers)
Commits related to this issue
- Merge pull request #672 from pgrimaud/master Add temporary workaround for login #670 — committed to postaddictme/instagram-php-scraper by raiym 4 years ago
I published a workaround on my scrapper. It seems working for me, some people could try it : https://github.com/pgrimaud/instagram-user-feed/commit/96ad4cf54d1ad331b337f325c73e664999a6d066 ?
Just clone my repository, edit this file and run it.
If it will conclusive, I will open a PR on this repository.
Thanks for tests and feedback 😄
for checkpoint_required
Short solution is to create new account
i search on the internet to fix challenge, it need to Temporarily disable account, i do this for old account, and maybe wait 3days or 1 week, before enabling again.
Thank you so much @pgrimaud!!! I changed Login() function of Instagram.php file to your approach and now I no longer get error 400 Bad Request:
We need to find a way to generate enc_password form field value.
Got the same error on my scraper too : https://github.com/pgrimaud/instagram-user-feed/issues/65
I found this, which could help us : https://www.bountysource.com/issues/87593270-add-enc_password-header-for-requests-version
I’m actually working on it. If someone has good knowledge about crypto in JavaScript (AES), please contact me.
@jangrewe hehe sorry i never thought UA important, after getting this error again, i try to change it, and it works,
just debugging thing, sometimes try to hardcode 😅
thanks for mention the function 😃
I have been getting the 200 error as well. I tried to comment out line 385 and I even though I no longer get the error I also can not access any images. This is what I get on sentry
Response code is 200. Body: <!DOCTYPE html>
<html lang="en" class="no-js not-logged-in client-root touch"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge">Login • Instagram
</title> <link rel="preload" href="/static/bundles/es6/ConsumerAsyncCommons.css/638f1bd337c8.css" as="style" type="text/css" crossorigin="anonymous" />it works using this
But I need to create new account
Old account always ask confirmation everytime script running
i try to change variable password to enc_password
https://github.com/postaddictme/instagram-php-scraper/blob/6503db29f6bfbf36bbd281da88f73fda279033f5/src/InstagramScraper/Instagram.php#L1540-L1548
but got respond like this
{“code”:400,“raw_body”:“{"message": "checkpoint_required", "checkpoint_url": "/challenge/6242737647/GMoK4dsqH9/", "lock": false, "status": "fail"}”,“body”:{“message”:“checkpoint_required”,“checkpoint_url”:“/challenge/6242737647/GMoK4dsqH9/”,“lock”:false,“status”:“fail”}
using encoded password from browser login
and then confirmation show up