Skip to content

Commit 230f1eb

Browse files
authored
fix: fix #1085 (#1087)
1 parent 3ef6f68 commit 230f1eb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/InstagramScraper/Instagram.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,14 @@ public function getMediaByUrl($mediaUrl)
989989
}
990990

991991
$mediaArray = $this->decodeRawBodyToJson($response->raw_body);
992-
if (!isset($mediaArray['items'])) {
992+
if (!isset($mediaArray['graphql']['shortcode_media']) && !isset($mediaArray['items'])) {
993993
throw new InstagramException('Media with this code does not exist');
994994
}
995-
return Media::create(current($mediaArray['items']));
995+
if (isset($mediaArray['graphql']['shortcode_media'])) {
996+
return Media::create($mediaArray['graphql']['shortcode_media']);
997+
} else {
998+
return Media::create(current($mediaArray['items']));
999+
}
9961000
}
9971001

9981002
/**

src/InstagramScraper/Model/Media.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ protected function initPropertiesCustom($value, $prop, $arr)
572572
{
573573
switch ($prop) {
574574
case 'pk':
575+
case 'id':
575576
$this->id = $value;
576577
break;
577578
case 'type':

0 commit comments

Comments
 (0)