A
A
Analka2019-09-10 22:53:20
HTML
Analka, 2019-09-10 22:53:20

This field is required mgp25?

Tell me, where did you go wrong?
issues

Undefined index: user_id

var_dump($customResponse);  ===  { ["message"]=> string(23) "This field is required." ["status"]=> string(4) "fail" }

at
$debug = false;
        $truncatedDebug = false;
        $user_id = '';
        $challenge_id = '';

        $verification_method = 0; //0 = SMS, 1 = Email

        function readln($prompt) {
            if ( PHP_OS === 'WINNT' ) {
                echo $prompt;

                return trim( (string) stream_get_line( STDIN, 6, "\n" ) );
            }

            return trim(readline("$prompt"));
        }


        Instagram::$allowDangerousWebUsageAtMyOwnRisk = true;

        $ig  = new Instagram($debug, $truncatedDebug);

        try{
            $loginResponse = $ig->login($request->login, $request->password);
            $user_id = $ig->account_id;

            if ( $loginResponse !== null && $loginResponse->isTwoFactorRequired() ) {
                return '2FA not supported in this example';
            }

            if ( $loginResponse instanceof LoginResponse || $loginResponse === null ) {
                return "Not a challenge required exception...\n";
            }

            return 'Logged in!';
        }catch (\Exception $e) {
            if ( ! method_exists( $e, 'getResponse' ) ) {
                echo $e->getMessage();
                exit;
            }
            $response = $e->getResponse();
            var_dump($response);

            if ($e instanceof ChallengeRequiredException) {
            sleep(5);

            $customResponse = $ig->request(substr($e->getResponse()->getChallenge()->getApiPath(), 1))->setNeedsAuth(false)->addPost("choice", 0)->getDecodedResponse();
            var_dump($customResponse);
            if (is_array($customResponse)) {
                $user_id = $customResponse['user_id'];
                $challenge_id  = $customResponse['nonce_code'];
            } else {
                //Other stuff.
            }
                try {
                    $code = readln( 'Code that you received via ' . ( $verification_method ? 'email' : 'sms' ) . ':' );
                    $customResponse = $ig->request( "challenge/$user_id/$challenge_id/" )->setNeedsAuth( false )->addPost( 'security_code', $code )->getDecodedResponse();

                    if ( ! is_array( $customResponse ) ) {
                        echo "Weird response from challenge validation...\n";
                        //var_dump( $customResponse );
                        exit;
                    }

                    if ( $customResponse['status'] === 'ok' && (int) $customResponse['logged_in_user']['pk'] === (int) $user_id ) {
                        echo 'Finished, logged in successfully! Run this file again to validate that it works.';
                    } else {
                        echo "Probably finished...\n";
                       //var_dump( $customResponse );
                    }
                } catch ( Exception $ex ) {
                    echo $ex->getMessage();
                }
        } else {
                //Other stuff.
            }
            return 'Something went wrong: '.$e->getMessage()."\n";
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2018-03-30
@devellopah

The usual table, what confuses you? What is the title combined via colspan?

P
Puma Thailand, 2019-09-11
@opium

Well, what exactly is not clear, you don’t have such an index

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question