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

$twoStepVerificator must be an instance of TwoStepVerificationInterface #810

Closed
alabamaster opened this issue Nov 9, 2020 · 7 comments
Closed
Labels

Comments

@alabamaster
Copy link

Fatal error: Uncaught InstagramScraper\Exception\InstagramAuthException: $twoStepVerificator must be an instance of TwoStepVerificationInterface. in /home/web/.../vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php:1751 Stack trace: #0 /home/web/.../vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php(1650): InstagramScraper\Instagram->verifyTwoStep(Object(InstagramScraper\Http\Response), Array, NULL) #1 /home/web/.../tests/index.php(10): InstagramScraper\Instagram->login() #2 {main} thrown in /home/web/.../vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php on line 1751
this in paginateAccountMediaByUsername.php

@Theder-old
Copy link

Probably, Instagram has marked your account as suspicious, or you are logging in from a non-standard location. There are three solutions to this problem:

  1. You have to use InstagramScraper\Instagram::login(false, true). Second flag (true) enables two step verification. You need to enter the code to console after it is sent.
  2. Use function $instagram->setUserAgent($userAgent);, enter the useragent you usually use to login in instagram. Also check example file https://github.com/postaddictme/instagram-php-scraper/blob/master/examples/setCustomCookies.php. For more complex work with this scraper you have to save coockies and set custom in each login.
  3. Check this file, if you need security code by email auto comfirm. https://github.com/postaddictme/instagram-php-scraper/blob/master/examples/twoStepAutoVerification/loginWithEmailAutoCponfirm.php

@alabamaster
Copy link
Author

Ty rly
Maybe, there is an instruction or some kind of guide to all this?

@pabloldeoliveira
Copy link

Hi, try this example:

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->setUserAgent('User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0');
$instagram->login(false, true);
$instagram->saveSession();

This works for me.

@aashari
Copy link

aashari commented Dec 10, 2020

Hi, try this example:

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->setUserAgent('User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0');
$instagram->login(false, true);
$instagram->saveSession();

This works for me.

This works for me too

@ptfcpro
Copy link

ptfcpro commented Feb 17, 2021

Hi, try this example:
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->setUserAgent('User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0');
$instagram->login(false, true);
$instagram->saveSession();
This works for me.

This works for me too

And for me too

@suraj853
Copy link

Probably, Instagram has marked your account as suspicious, or you are logging in from a non-standard location. There are three solutions to this problem:

  1. You have to use InstagramScraper\Instagram::login(false, true). Second flag (true) enables two step verification. You need to enter the code to console after it is sent.
  2. Use function $instagram->setUserAgent($userAgent);, enter the useragent you usually use to login in instagram. Also check example file https://github.com/postaddictme/instagram-php-scraper/blob/master/examples/setCustomCookies.php. For more complex work with this scraper you have to save coockies and set custom in each login.
  3. Check this file, if you need security code by email auto comfirm. https://github.com/postaddictme/instagram-php-scraper/blob/master/examples/twoStepAutoVerification/loginWithEmailAutoCponfirm.php

2nd one worked the best for me. Using custom cookies is the best option because by using the first option, Instagram always sent mail for reminding new login which just occurs. It will be marked suspicious sooner or later if you do not use cookies.

Thanks

@stale
Copy link

stale bot commented Jun 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants