Skip to content

Commit

Permalink
Merge pull request #672 from pgrimaud/master
Browse files Browse the repository at this point in the history
Add temporary workaround for login #670
  • Loading branch information
raiym authored May 18, 2020
2 parents 6503db2 + 472acbc commit f98597d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/InstagramScraper/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ private function generateHeaders($session, $gisToken = null)
$headers['x-instagram-gis'] = $gisToken;
}
}

if (empty($headers['x-csrftoken'])) {
$headers['x-csrftoken'] = md5(uniqid()); // this can be whatever, insta doesn't like an empty value
}
}

return $headers;
}
Expand Down Expand Up @@ -745,7 +745,7 @@ public function getMediaCommentsByCode($code, $count = 10, $maxId = null)

$commentsUrl = Endpoints::getCommentsBeforeCommentIdByCode($variables);
$response = Request::get($commentsUrl, $this->generateHeaders($this->userSession, $this->generateGisToken($variables)));

if (static::HTTP_OK !== $response->code) {
throw new InstagramException('Response code is ' . $response->code . '. Body: ' . static::getErrorBody($response->body) . ' Something went wrong. Please report issue.', $response->code);
}
Expand Down Expand Up @@ -774,7 +774,7 @@ public function getMediaCommentsByCode($code, $count = 10, $maxId = null)
$comments[] = Comment::create($commentArray['node']);
$index++;
}

if ($count > $numberOfComments) {
$count = $numberOfComments;
}
Expand Down Expand Up @@ -1256,7 +1256,7 @@ public function getLocationById($facebookLocationId)
return Location::create($jsonResponse['graphql']['location']);
}


/**
* @param string $accountId Account id of the profile to query
* @param int $count Total followers to retrieve
Expand Down Expand Up @@ -1319,7 +1319,7 @@ public function getPaginateFollowers($accountId, $count = 20, $pageSize = 20, $d
if (count($edgesArray) === 0) {
throw new InstagramException('Failed to get followers of account id ' . $accountId . '. The account is private.', static::HTTP_FORBIDDEN);
}

foreach ($edgesArray as $edge) {
$accounts[] = $edge['node'];
$index++;
Expand All @@ -1342,7 +1342,7 @@ public function getPaginateFollowers($accountId, $count = 20, $pageSize = 20, $d
}
}
$toReturn = [
'hasNextPage' => $lastPagingInfo['has_next_page'],
'hasNextPage' => $lastPagingInfo['has_next_page'],
'nextPage' => $lastPagingInfo['end_cursor'],
'accounts' => $accounts
];
Expand Down Expand Up @@ -1435,8 +1435,8 @@ public function getPaginateFollowing($accountId, $count = 20, $pageSize = 20, $d
}
}
$toReturn = [
'hasNextPage' => $lastPagingInfo['has_next_page'],
'nextPage' => $lastPagingInfo['end_cursor'],
'hasNextPage' => $lastPagingInfo['has_next_page'],
'nextPage' => $lastPagingInfo['end_cursor'],
'accounts' => $accounts
];
return $toReturn;
Expand Down Expand Up @@ -1545,7 +1545,7 @@ public function login($force = false, $twoStepVerificator = null)
'user-agent' => $this->getUserAgent(),
];
$response = Request::post(Endpoints::LOGIN_URL, $headers,
['username' => $this->sessionUsername, 'password' => $this->sessionPassword]);
['username' => $this->sessionUsername, 'enc_password' => '#PWD_INSTAGRAM_BROWSER:0:' . time() . ':' . $this->sessionPassword]);

if ($response->code !== static::HTTP_OK) {
if (
Expand Down

0 comments on commit f98597d

Please sign in to comment.