diff --git a/src/InstagramScraper/Endpoints.php b/src/InstagramScraper/Endpoints.php index 1f6b94d5..a0c63d3a 100644 --- a/src/InstagramScraper/Endpoints.php +++ b/src/InstagramScraper/Endpoints.php @@ -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}}'; diff --git a/src/InstagramScraper/Instagram.php b/src/InstagramScraper/Instagram.php index 4b71d1d2..0a39db75 100644 --- a/src/InstagramScraper/Instagram.php +++ b/src/InstagramScraper/Instagram.php @@ -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.'); @@ -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, @@ -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; }