M
M
Maxim2019-09-04 12:02:13
PHP
Maxim, 2019-09-04 12:02:13

Instagram private api login?

trying to get user id

Instagram::$allowDangerousWebUsageAtMyOwnRisk=true;
        $ig = new Instagram(true,true);
        $ig->login($request->login, $request->password);

        $userId = $ig->people->getUserIdForName($request->login);
        if ($userId) return response()->json([
            'error' => 1,
            'message' => $userId
        ]);else return response()->json([
            'error' => 1,
            'message' => 'Нет аккаунта'
        ]);

but gives out
I
nstagramAPI\Response\LoginResponse: Challenge required.

I try like this, but it also gives the same error
Instagram::$allowDangerousWebUsageAtMyOwnRisk=true;

        $debug = true;
        $truncatedDebug = false;
        $ig = new Instagram($debug, $truncatedDebug);
        try {
            $loginResponse = $ig->login($request->login, $request->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($request->login, $request->password, $twoFactorIdentifier, $verificationCode);
            }
        } catch (\Exception $e) {
            return response()->json([
                'error' => 1,
                'message' => 'Something went wrong: '.$e->getMessage()."\n"
            ]);
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
deadnice, 2019-09-04
@deadnice

Instagram private api login?

No.
Basically, did you try to google the error?
This question has already been discussed on the toaster How to solve the "Challenge required" in mgp25/instagram-api?
Challenge required
asks to verify the account via sms or email
Which one do you use?

P
Puma Thailand, 2019-09-04
@opium

In Russia, you need to go through the challenge, in the second code with SMS, there are no errors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question