postaddictme / instagram-php-scraper

Get account information, photos, videos, stories and comments.
https://packagist.org/packages/raiym/instagram-php-scraper
MIT License
3.09k stars 799 forks source link

cannot loign - http 400 "checkpoint required" #733

Closed badpenguin closed 3 years ago

badpenguin commented 4 years ago

Its 7 days maybe that i cannot login anymore. The response is 400 with checkpoint_required. I already tried to say them "it was me" but without luck. Any suggestions on what to do?

Exception is in src/InstagramScraper/Instagram.php:1527 Something went wrong. Please report issue.

This is the response:

Unirest\Response Object
(
    [code] => 400
    [raw_body] => {"message": "checkpoint_required", "checkpoint_url": "/challenge/37359509870/Y2NVyg60Sv/", "lock": false, "status": "fail"}
    [body] => stdClass Object
        (
            [message] => checkpoint_required
            [checkpoint_url] => /challenge/37359509870/Y2NVyg60Sv/
            [lock] => 
            [status] => fail
        )

    [headers] => Array
        (
            [0] => HTTP/1.1 400 Bad Request
            [Content-Type] => application/json; charset=utf-8
            [ig-set-password-encryption-web-key-id] => 87
            [ig-set-password-encryption-web-pub-key] => 8dd9aad29d9a614c338cff479f850d3ec57c525c33b3f702ab65e9e057fc087e
            [ig-set-password-encryption-web-key-version] => 9
            [x-robots-tag] => noindex
            [Vary] => Accept-Language, Cookie
            [Content-Language] => en
            [Date] => Sun, 26 Jul 2020 12:42:30 GMT
            [Strict-Transport-Security] => max-age=31536000
            [Cache-Control] => private, no-cache, no-store, must-revalidate
            [Pragma] => no-cache
            [Expires] => Sat, 01 Jan 2000 00:00:00 GMT
            [X-Frame-Options] => SAMEORIGIN
            [content-security-policy] => report-uri https://www.instagram.com/security/csp_report/; default-src 'self' https://www.instagram.com; img-src https: data: blob:; font-src https: data:; media-src 'self' blob: https://www.instagram.com https://*.cdninstagram.com https://*.fbcdn.net; manifest-src 'self' https://www.instagram.com; script-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://*.cdninstagram.com wss://www.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:; style-src 'self' https://*.www.instagram.com https://www.instagram.com 'unsafe-inline'; connect-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://graph.instagram.com https://*.graph.instagram.com https://*.cdninstagram.com https://api.instagram.com https://i.instagram.com wss://www.instagram.com wss://edge-chat.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net chrome-extension://boadgeojelhgndaghljhdicfkmllpafd blob:; worker-src 'self' blob: https://www.instagram.com; frame-src 'self' https://instagram.com https://www.instagram.com https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src 'none'; upgrade-insecure-requests
            [X-Content-Type-Options] => nosniff
            [X-XSS-Protection] => 0
            [x-aed] => 15
            [Access-Control-Expose-Headers] => X-IG-Set-WWW-Claim
            [Set-Cookie] => Array
                (
                    [0] => ig_did=EDCD6FF1-DE7E-4AF7-88BF-FD474325B3EE; Domain=.instagram.com; expires=Wed, 24-Jul-2030 12:42:30 GMT; HttpOnly; Max-Age=315360000; Path=/; Secure
                    [1] => csrftoken=ZOWCBj2RmHv2o2vN8UNR87oPmYK0UxLU; Domain=.instagram.com; expires=Sun, 25-Jul-2021 12:42:30 GMT; Max-Age=31449600; Path=/; Secure
                    [2] => rur=ATN; Domain=.instagram.com; HttpOnly; Path=/; Secure
                    [3] => mid=Xx16NgABAAFx6rg2IyxxbXJFwXHY; Domain=.instagram.com; expires=Wed, 24-Jul-2030 12:42:30 GMT; Max-Age=315360000; Path=/; Secure
                )

            [X-FB-TRIP-ID] => 1679558926
            [Alt-Svc] => h3-29=":443"; ma=3600,h3-27=":443"; ma=3600
            [Connection] => keep-alive
            [Content-Length] => 123
        )

)
jaysongyn commented 4 years ago

same issue here

badpenguin commented 4 years ago

ok sorry .... found so many bug similar to mine, so i'll close it for now

jaysongyn commented 4 years ago

@badpenguin Maybe can help you.

I create my script

 $cache =  new Psr16Adapter('Files');

    $instagram = \InstagramScraper\Instagram::withCredentials('jayson.tec', '******', $cache);
    $instagram->login(false, true); // will use cached session if you want to force login $instagram->login(true)
    $instagram->saveSession();  //DO NOT forget this in order to save the session, otherwise have no sense

    sleep(2); // Delay to mimic user

    $username = 'jayson.tec';
    $followers = [];
    $account = $instagram->getAccount($username);

And I run the command from terminal

php /Users/jaysonsantos/projects/instagran/test.php

First time ask for verification code.

But even after put verification code, after a few request ask the verification code again.

I change the userAgent, I'm using an mac computer, now is working

private $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36';

badpenguin commented 4 years ago

@jaysongyn thanks i see i can enter the code received via email... this will not work in a crontab too :-( I used setUserAgent() after creating instance with withCredentials().

Anyway two big problems: 1) cache does not work and session are not reused - it ask me everytime the password

$adapter = new Psr16Adapter('Files', new ConfigurationOption(array(
      'path' => $cacheDir
)));
$this->scraper = Instagram::withCredentials( configGet('instagram_username'), configGet('instagram_password'), $adapter);
$this->scraper->setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/83.0.4103.44 Chrome/83.0.4103.44 Safari/537.36');

2) running "getMediasByTag()" decoding does not work :-(

src/InstagramScraper/Instagram.php:941 Response decoding failed. Returned data corrupted or this library outdated. Please report issue
jaysongyn commented 4 years ago

@badpenguin here has an example how you can verify by email

https://github.com/postaddictme/instagram-php-scraper/tree/master/examples/twoStepAutoVerification

My session is working after I change user agent. The fist time I type the code manually because session is one year.

badpenguin commented 4 years ago

@badpenguin here has an example how you can verify by email

https://github.com/postaddictme/instagram-php-scraper/tree/master/examples/twoStepAutoVerification

My session is working after I change user agent. The fist time I type the code manually because session is one year.

Thank you. Does not work for me. Probably I've to create a new account.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.