Skip to content

Commit bf2f2f6

Browse files
cuchacJoe
and
Joe
authored
Working getAccountInfo again (#1078)
Co-authored-by: Joe <joe@wpj.cz>
1 parent 73da951 commit bf2f2f6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/InstagramScraper/Endpoints.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Endpoints
1010
const MEDIA_LINK = 'https://www.instagram.com/p/{code}';
1111
const ACCOUNT_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables={variables}';
1212
const ACCOUNT_TAGGED_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=be13233562af2d229b008d2976b998b5&variables={variables}';
13-
const ACCOUNT_JSON_INFO = 'https://www.instagram.com/{username}/?__a=1';
13+
const ACCOUNT_JSON_INFO = 'https://www.instagram.com/{username}/?__a=1&__d=dis';
1414
const ACCOUNT_ACTIVITY = 'https://www.instagram.com/accounts/activity/?__a=1';
1515
const MEDIA_JSON_INFO = 'https://www.instagram.com/p/{code}/?__a=1';
1616
const MEDIA_JSON_BY_LOCATION_ID = 'https://www.instagram.com/explore/locations/{{facebookLocationId}}/?__a=1&max_id={{maxId}}';

src/InstagramScraper/Instagram.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,8 @@ public function login($force = false, $twoStepVerificator = null)
22272227
*/
22282228
public function loginWithSessionId($sessionId)
22292229
{
2230-
$session = ['sessionid' => $sessionId, 'csrftoken' => md5( rand( 1, 5000 ) )];
2230+
$sessionParts = explode('%',$sessionId);
2231+
$session = ['sessionid' => $sessionId, 'ds_user_id' => $sessionParts[0], 'csrftoken' => md5( rand( 1, 5000 ) )];
22312232

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

22632264
$sessionId = $session['sessionid'];
2265+
$dsuserId = $session['ds_user_id'];
22642266
$csrfToken = $session['csrftoken'];
22652267
$headers = [
2266-
'cookie' => "ig_cb=1; csrftoken=$csrfToken; sessionid=$sessionId;",
2268+
'cookie' => "ig_cb=1; csrftoken=$csrfToken; sessionid=$sessionId; ds_user_id=$dsuserId",
22672269
'referer' => Endpoints::BASE_URL . '/',
22682270
'x-csrftoken' => $csrfToken,
22692271
'X-CSRFToken' => $csrfToken,
@@ -2274,9 +2276,6 @@ public function isLoggedIn($session = null)
22742276
return false;
22752277
}
22762278
$cookies = $this->parseCookies($response->headers);
2277-
if (!isset($cookies['ds_user_id'])) {
2278-
return false;
2279-
}
22802279
return true;
22812280
}
22822281

0 commit comments

Comments
 (0)