Skip to content

Commit

Permalink
Add &__d=dis to media URL request (#1083)
Browse files Browse the repository at this point in the history
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"}'`
  • Loading branch information
kingkool68 authored Jul 17, 2022
1 parent bf2f2f6 commit 0b0c2d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/InstagramScraper/Endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Endpoints
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&__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_INFO = 'https://www.instagram.com/p/{code}/?__a=1&__d=dis';
const MEDIA_JSON_BY_LOCATION_ID = 'https://www.instagram.com/explore/locations/{{facebookLocationId}}/?__a=1&max_id={{maxId}}';
const MEDIA_JSON_BY_TAG = 'https://www.instagram.com/explore/tags/{tag}/?__a=1&max_id={max_id}';
const GENERAL_SEARCH = 'https://www.instagram.com/web/search/topsearch/?query={query}&count={count}';
Expand Down
2 changes: 1 addition & 1 deletion src/InstagramScraper/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ public function getMediaByUrl($mediaUrl)
if (filter_var($mediaUrl, FILTER_VALIDATE_URL) === false) {
throw new InvalidArgumentException('Malformed media url');
}
$response = Request::get(rtrim($mediaUrl, '/') . '/?__a=1', $this->generateHeaders($this->userSession));
$response = Request::get(rtrim($mediaUrl, '/') . '/?__a=1&__d=dis', $this->generateHeaders($this->userSession));

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

0 comments on commit 0b0c2d4

Please sign in to comment.