Skip to content

Commit 0b0c2d4

Browse files
authored
Add &__d=dis to media URL request (#1083)
Without this Instagram returns a 200 response but with an error message: `for (;;);{"__ar":1,"error":1357004,"errorSummary":"Sorry, something went wrong","errorDescription":"Please try closing and re-opening your browser window.","payload":null,"hsrp":{"hblp":{"consistency":{"rev":1005858897}}},"lid":"7121366591489386466"}'`
1 parent bf2f2f6 commit 0b0c2d4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/InstagramScraper/Endpoints.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Endpoints
1212
const ACCOUNT_TAGGED_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=be13233562af2d229b008d2976b998b5&variables={variables}';
1313
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';
15-
const MEDIA_JSON_INFO = 'https://www.instagram.com/p/{code}/?__a=1';
15+
const MEDIA_JSON_INFO = 'https://www.instagram.com/p/{code}/?__a=1&__d=dis';
1616
const MEDIA_JSON_BY_LOCATION_ID = 'https://www.instagram.com/explore/locations/{{facebookLocationId}}/?__a=1&max_id={{maxId}}';
1717
const MEDIA_JSON_BY_TAG = 'https://www.instagram.com/explore/tags/{tag}/?__a=1&max_id={max_id}';
1818
const GENERAL_SEARCH = 'https://www.instagram.com/web/search/topsearch/?query={query}&count={count}';

src/InstagramScraper/Instagram.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ public function getMediaByUrl($mediaUrl)
977977
if (filter_var($mediaUrl, FILTER_VALIDATE_URL) === false) {
978978
throw new InvalidArgumentException('Malformed media url');
979979
}
980-
$response = Request::get(rtrim($mediaUrl, '/') . '/?__a=1', $this->generateHeaders($this->userSession));
980+
$response = Request::get(rtrim($mediaUrl, '/') . '/?__a=1&__d=dis', $this->generateHeaders($this->userSession));
981981

982982
if (static::HTTP_NOT_FOUND === $response->code) {
983983
throw new InstagramNotFoundException('Media with given code does not exist or account is private.');

0 commit comments

Comments
 (0)