instagram-user-feed icon indicating copy to clipboard operation
instagram-user-feed copied to clipboard

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

Open almod90 opened this issue 1 year ago • 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

almod90 avatar Jul 18 '22 00:07 almod90

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

almod90 avatar Jul 18 '22 00:07 almod90

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.

h-behme avatar Jul 18 '22 22:07 h-behme

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?

h-behme avatar Jul 19 '22 08:07 h-behme

same problem

jailrobeta avatar Jul 31 '22 14:07 jailrobeta

same problem

ster avatar Aug 02 '22 08:08 ster

same, please see https://github.com/pgrimaud/instagram-user-feed/issues/341#issuecomment-1321908720

aroy314 avatar Nov 21 '22 11:11 aroy314