Skip to content

Commit

Permalink
Merge pull request #376 from developedsoftware/master
Browse files Browse the repository at this point in the history
login bug fix
  • Loading branch information
raiym authored May 29, 2018
2 parents c2f653e + 36daeca commit c36ca08
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/InstagramScraper/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -1201,9 +1201,12 @@ public function login($force = false, $support_two_step_verification = false)
if ($response->code !== 200) {
throw new InstagramException('Response code is ' . $response->code . '. Body: ' . static::getErrorBody($response->body) . ' Something went wrong. Please report issue.');
}
$cookies = static::parseCookies($response->headers['Set-Cookie']);
preg_match('/"csrf_token":"(.*?)"/', $response->body, $match);
if(isset($match[1])) {
$csrfToken = $match[1];
}
$cookies = static::parseCookies($response->headers['Set-Cookie']);
$mid = $cookies['mid'];
$csrfToken = $cookies['csrftoken'];
$headers = ['cookie' => "csrftoken=$csrfToken; mid=$mid;",
'referer' => Endpoints::BASE_URL . '/',
'x-csrftoken' => $csrfToken,
Expand Down

0 comments on commit c36ca08

Please sign in to comment.