Instagram-php-scraper: $twoStepVerificator must be an instance of TwoStepVerificationInterface

Created on 9 Nov 2020  路  6Comments  路  Source: postaddictme/instagram-php-scraper

Fatal error: Uncaught InstagramScraperExceptionInstagramAuthException: $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): InstagramScraperInstagram->verifyTwoStep(Object(InstagramScraperHttpResponse), Array, NULL) #1 /home/web/.../tests/index.php(10): InstagramScraperInstagram->login() #2 {main} thrown in /home/web/.../vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php on line 1751
this in paginateAccountMediaByUsername.php

Most helpful comment

Hi, try this example:

$instagram = new InstagramScraperInstagram(new GuzzleHttpClient());
$instagram = InstagramScraperInstagram::withCredentials(new GuzzleHttpClient(), '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.

All 6 comments

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

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

Hi, try this example:

$instagram = new InstagramScraperInstagram(new GuzzleHttpClient());
$instagram = InstagramScraperInstagram::withCredentials(new GuzzleHttpClient(), '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.

Hi, try this example:

$instagram = new InstagramScraperInstagram(new GuzzleHttpClient());
$instagram = InstagramScraperInstagram::withCredentials(new GuzzleHttpClient(), '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

Hi, try this example:
$instagram = new InstagramScraperInstagram(new GuzzleHttpClient());
$instagram = InstagramScraperInstagram::withCredentials(new GuzzleHttpClient(), '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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tvvinman picture Tvvinman  路  7Comments

JOniiX picture JOniiX  路  6Comments

juangrimm picture juangrimm  路  8Comments

pauloamorimbr picture pauloamorimbr  路  7Comments

luengwaiban picture luengwaiban  路  5Comments