pgrimaud/instagram-user-feed

midCookie: Call to a member function getValue() on null

almod90 opened this issue · 6 comments

Version(s) affected: 6.15.1

Description
Running example with challenge with my own credentials results in the following error:

PHP Fatal error:  Uncaught Error: Call to a member function getValue() on null in /var/www/html/vendor/pgrimaud/instagram-user-feed/src/Instagram/Auth/Checkpoint/Challenge.php:68
Stack trace:
#0 /var/www/html/vendor/pgrimaud/instagram-user-feed/src/Instagram/Auth/Login.php(138): Instagram\Auth\Checkpoint\Challenge->fetchChallengeContent()
#1 /var/www/html/vendor/pgrimaud/instagram-user-feed/src/Instagram/Auth/Login.php(101): Instagram\Auth\Login->checkpointChallenge()
#2 /var/www/html/vendor/pgrimaud/instagram-user-feed/src/Instagram/Api.php(126): Instagram\Auth\Login->process()
#3 /var/www/html/test.php(19): Instagram\Api->login()
#4 {main}
  thrown in /var/www/html/vendor/pgrimaud/instagram-user-feed/src/Instagram/Auth/Checkpoint/Challenge.php on line 68

There are actually no 'mid' cookie inside cookieJar

If I remove everything related with midCookie process walks through, but the code is not sent to email in the end.

Tested this on the 5.6 (php7.3) and 9.2 (php 8.1) laravel versions both the same result

Actually, my assumption is that on new instagram visit (e.g. in incognito tab) it asks to accept cookies, and only then mid cookie is set via https://www.instagram.com/data/shared_data/ ajax request

Have the same issue here, but I noticed the cookie notice (e.g. on https://instagram.com/accounts/login/) does not show up, when the ig_did cookie ist set. The value for it should be the device id available in shared_data I think. Then the mid-cookie should be set in response.

I could bypass the cookie notice by calling https://graphql.instagram.com/graphql/ to "register" (?) the device id and then calling e.g. https://instagram.com/accounts/login/ to get the midCookie. It can look like this:

src/Instagram/Auth/Login.php:L83

$this->client->request('POST', 'https://graphql.instagram.com/graphql/', [
    'headers' => [
        'content-type' => 'application/x-www-form-urlencoded',
    ],
    'body' => http_build_query([
        'doc_id' => 3810865872362889,
        'variables' => json_encode([
            "ig_did" => $data->device_id,
            "first_party_tracking_opt_in" => true,
            "third_party_tracking_opt_in" => false,
            "input" => [
                "client_mutation_id" => 0
            ]
        ]),
    ])
]);

$this->client->request('GET', 'https://instagram.com/accounts/login/', [
    'headers' => [
        'cookie' => 'ig_did=' . $data->device_id . '; csrftoken=' . $data->config->csrf_token . ';',
        'x-csrftoken' => $data->config->csrf_token,
    ],
    'cookies' => $cookieJar,
]);

But maybe they changed to whole process, because then I just get an error
"Warning: Undefined property: stdClass::$Challenge" ( src/Instagram/Auth/Checkpoint/Challenge.php:L91 ) because there is not challenge in extra_data?

same problem

ster commented

same problem

same, please see #341 (comment)