Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

32 lines (24 sloc) 960 Bytes
<?php
set_time_limit(0);
date_default_timezone_set('UTC');
require __DIR__.'/../vendor/autoload.php';
/////// CONFIG ///////
$username = '';
$password = '';
$debug = true;
$truncatedDebug = false;
//////////////////////
$ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);
try {
$loginResponse = $ig->login($username, $password);
if ($loginResponse !== null && $loginResponse->isTwoFactorRequired()) {
$twoFactorIdentifier = $loginResponse->getTwoFactorInfo()->getTwoFactorIdentifier();
// The "STDIN" lets you paste the code via terminal for testing.
// You should replace this line with the logic you want.
// The verification code will be sent by Instagram via SMS.
$verificationCode = trim(fgets(STDIN));
$ig->finishTwoFactorLogin($username, $password, $twoFactorIdentifier, $verificationCode);
}
} catch (\Exception $e) {
echo 'Something went wrong: '.$e->getMessage()."\n";
}
You can’t perform that action at this time.