Skip to content

Commit

Permalink
Merge pull request #253 from mazguhin/master
Browse files Browse the repository at this point in the history
Update getPaginateMediasByTag
  • Loading branch information
raiym authored Jan 9, 2018
2 parents 464f628 + 4a43cab commit f770e32
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/InstagramScraper/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,23 +648,23 @@ public function getPaginateMediasByTag($tag, $maxId = '')
throw new InstagramException('Response decoding failed. Returned data corrupted or this library outdated. Please report issue');
}

if (empty($arr['tag']['media']['count'])) {
if (empty($arr['graphql']['hashtag']['edge_hashtag_to_media']['count'])) {
return $toReturn;
}

$nodes = $arr['tag']['media']['nodes'];
$nodes = $arr['graphql']['hashtag']['edge_hashtag_to_media']['edges'];

if (empty($nodes)) {
return $toReturn;
}

foreach ($nodes as $mediaArray) {
$medias[] = Media::create($mediaArray);
$medias[] = Media::create($mediaArray['node']);
}

$maxId = $arr['tag']['media']['page_info']['end_cursor'];
$hasNextPage = $arr['tag']['media']['page_info']['has_next_page'];
$count = $arr['tag']['media']['count'];
$maxId = $arr['graphql']['hashtag']['edge_hashtag_to_media']['page_info']['end_cursor'];
$hasNextPage = $arr['graphql']['hashtag']['edge_hashtag_to_media']['page_info']['has_next_page'];
$count = $arr['graphql']['hashtag']['edge_hashtag_to_media']['count'];

$toReturn = [
'medias' => $medias,
Expand Down

0 comments on commit f770e32

Please sign in to comment.