Skip to content

Commit c36ca08

Browse files
authored
Merge pull request #376 from developedsoftware/master
login bug fix
2 parents c2f653e + 36daeca commit c36ca08

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/InstagramScraper/Instagram.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,12 @@ public function login($force = false, $support_two_step_verification = false)
12011201
if ($response->code !== 200) {
12021202
throw new InstagramException('Response code is ' . $response->code . '. Body: ' . static::getErrorBody($response->body) . ' Something went wrong. Please report issue.');
12031203
}
1204-
$cookies = static::parseCookies($response->headers['Set-Cookie']);
1204+
preg_match('/"csrf_token":"(.*?)"/', $response->body, $match);
1205+
if(isset($match[1])) {
1206+
$csrfToken = $match[1];
1207+
}
1208+
$cookies = static::parseCookies($response->headers['Set-Cookie']);
12051209
$mid = $cookies['mid'];
1206-
$csrfToken = $cookies['csrftoken'];
12071210
$headers = ['cookie' => "csrftoken=$csrfToken; mid=$mid;",
12081211
'referer' => Endpoints::BASE_URL . '/',
12091212
'x-csrftoken' => $csrfToken,

0 commit comments

Comments
 (0)