There is a challenge problem with Instagram. I tried with many different proxy but nothing change.(In two factor authentication methods SMS, Backup Codes...) I deleted the session folder, but no luck. Everything, it gives an error of "Challenge required". I verify that it was me on my Instagram, but when running the script I get the same error.
Code
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use InstagramAPI\Instagram;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('home');
}
public function test(Request $request){
if($request->get('code')){
$code = $request->get('code');
}
$username = "*****";
$password = "*****";
// Set allow dangerous
Instagram::$allowDangerousWebUsageAtMyOwnRisk = true;
$debug = false;
$ig = new Instagram($debug, false);
// Set proxy
$ig->setProxy('**PROXY ADRESS**');
try {
$loginResponse = $ig->login($username, $password);
print_r($loginResponse);
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));
// $verificationCode = trim($code);
print_r($ig->finishTwoFactorLogin($username, $password, $twoFactorIdentifier, strval($code), '2'));
// }
}
} catch (\Exception $e) {
echo $e->getMessage();
}
}
}
Debug Log
InstagramAPI\Response\LoginResponse: Challenge required.User not logged in. Please call login() and then try again.
There is a challenge problem with Instagram. I tried with many different proxy but nothing change.(In two factor authentication methods SMS, Backup Codes...) I deleted the session folder, but no luck. Everything, it gives an error of "Challenge required". I verify that it was me on my Instagram, but when running the script I get the same error.
Code
Debug Log