-1

I had a working script on my website named Instazood, which worked perfectly. Suddenly, a few days ago, I cannot use my script at all. 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.

I deleted the session folder, but no luck.

I read here that the problem is because of different IPs. But all of my devices use the same internet, and I have no proxy at all.

I have below error.

Fatal error: Uncaught InstagramAPI\Exception\ChallengeRequiredException: InstagramAPI\Response\LoginResponse: Challenge required.uring import data.
Sunil Kumar
  • 47
  • 1
  • 4
  • (Not clear to me what exactly you are even asking here, but - _“IInstazood automatically Like, Follow, Comment, Unfollow and Post on Instagram”_ sounds like the very definition of a _spam bot_ to me, so I don’t think that’s something should be supported here in the first place.) – 04FS Jan 24 '20 at 08:57
  • See the thing is when i login using Instagram mgp25 API then it gives me exception ChallengeRequiredException how to handle this exception in Codeigniter. – Sunil Kumar Jan 29 '20 at 03:14

2 Answers2

0

You need to use the two factor authentication methods provided by the library. Here is an example:

<?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";
}

On a related note, I am unable to download the package from GitHub since it was recently removed. Do you think you could upload just the mgp25/instagram-php package so that I can download it? I would be extremely grateful!!

0

composer require adrifkat/instagram-api to download the package @tblanks1980