Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response code is 403: Forbidden.Something went wrong. Please report issue. at this line $instagram->login(); #1132

Open
hammadev opened this issue Jan 6, 2024 · 1 comment

Comments

@hammadev
Copy link

hammadev commented Jan 6, 2024

Got Response code is 403: Forbidden.Something went wrong. Please report issue. at this line $instagram->login();

here's my code
$username = ''; $password = ''; $instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), $username, $password, new Psr16Adapter('Files')); // dd($instagram); $instagram->login(); // will use cached session if you want to force login $instagram->login(true) $instagram->saveSession(); //DO NOT forget this in order to save the session, otherwise have no sense $account = $instagram->getAccountById(3); echo $account->getUsername();

here's my response for dd($instagram);
image

@anraetsky
Copy link

It seems that Instagram changed a lot of things.

If you are on last version 0.12.9 and after debug you get error in line 2242 from src/InstagramScraper/Instagram.php
then you may fix the issue with this changes
Change preg_match('/\\\\"csrf_token\\\\":\\\\"(.*?)\\\\"/', $response->body, $match);
To: preg_match('/csrftoken=(.*?);/', $response->headers['Set-Cookie'][0], $match);
Or see diff from attached file (could be used as patch if replace the extension to .patch):
login.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants