Skip to content

Commit

Permalink
Fixes the loginWithCookies "Please login with instagram credentials" …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
deepvision7 committed Feb 24, 2024
1 parent 03762f1 commit ce39b81
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Instagram/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function process(): CookieJar

$html = (string) $baseRequest->getBody();

preg_match('/\\\"csrf_token\\\":\\\"(.*?)\\\"/', $html, $matches);
preg_match('/\"csrf_token\":\"(.*?)\"/', $html, $matches);

if (!isset($matches[1])) {
throw new InstagramAuthException('Unable to extract JSON data');
Expand Down Expand Up @@ -145,14 +145,10 @@ public function withCookies(array $session): CookieJar

$html = (string) $baseRequest->getBody();

preg_match('/\\\"csrf_token\\\":\\\"(.*?)\\\"/', $html, $matches);
preg_match('/\"csrf_token\":\"(.*?)\"/', $html, $matches);

if (isset($matches[1])) {
$data = $matches[1];

if (!isset($data->config->viewer) && !isset($data->config->viewerId)) {
throw new InstagramAuthException('Please login with instagram credentials.');
}
if (!isset($matches[1])) {
throw new InstagramAuthException('Unable to extract JSON data');
}

return $cookies;
Expand Down

0 comments on commit ce39b81

Please sign in to comment.