Skip to content

Commit

Permalink
Working getAccountInfo again (#1078)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe <[email protected]>
  • Loading branch information
cuchac and Joe authored Jul 8, 2022
1 parent 73da951 commit bf2f2f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/InstagramScraper/Endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Endpoints
const MEDIA_LINK = 'https://www.instagram.com/p/{code}';
const ACCOUNT_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables={variables}';
const ACCOUNT_TAGGED_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=be13233562af2d229b008d2976b998b5&variables={variables}';
const ACCOUNT_JSON_INFO = 'https://www.instagram.com/{username}/?__a=1';
const ACCOUNT_JSON_INFO = 'https://www.instagram.com/{username}/?__a=1&__d=dis';
const ACCOUNT_ACTIVITY = 'https://www.instagram.com/accounts/activity/?__a=1';
const MEDIA_JSON_INFO = 'https://www.instagram.com/p/{code}/?__a=1';
const MEDIA_JSON_BY_LOCATION_ID = 'https://www.instagram.com/explore/locations/{{facebookLocationId}}/?__a=1&max_id={{maxId}}';
Expand Down
9 changes: 4 additions & 5 deletions src/InstagramScraper/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,8 @@ public function login($force = false, $twoStepVerificator = null)
*/
public function loginWithSessionId($sessionId)
{
$session = ['sessionid' => $sessionId, 'csrftoken' => md5( rand( 1, 5000 ) )];
$sessionParts = explode('%',$sessionId);
$session = ['sessionid' => $sessionId, 'ds_user_id' => $sessionParts[0], 'csrftoken' => md5( rand( 1, 5000 ) )];

if (!$this->isLoggedIn($session)) {
throw new InstagramAuthException('Login with session went wrong. Please report issue.');
Expand Down Expand Up @@ -2261,9 +2262,10 @@ public function isLoggedIn($session = null)
}

$sessionId = $session['sessionid'];
$dsuserId = $session['ds_user_id'];
$csrfToken = $session['csrftoken'];
$headers = [
'cookie' => "ig_cb=1; csrftoken=$csrfToken; sessionid=$sessionId;",
'cookie' => "ig_cb=1; csrftoken=$csrfToken; sessionid=$sessionId; ds_user_id=$dsuserId",
'referer' => Endpoints::BASE_URL . '/',
'x-csrftoken' => $csrfToken,
'X-CSRFToken' => $csrfToken,
Expand All @@ -2274,9 +2276,6 @@ public function isLoggedIn($session = null)
return false;
}
$cookies = $this->parseCookies($response->headers);
if (!isset($cookies['ds_user_id'])) {
return false;
}
return true;
}

Expand Down

0 comments on commit bf2f2f6

Please sign in to comment.