From c4b560a05c6a374dfcc90b12a05ab46b644c2445 Mon Sep 17 00:00:00 2001 From: Xeus Date: Wed, 8 Jun 2022 07:45:49 +0100 Subject: [PATCH 1/2] getMediaLikesByCode returning 50 comments only resolved --- src/InstagramScraper/Instagram.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/InstagramScraper/Instagram.php b/src/InstagramScraper/Instagram.php index 4b71d1d2..1ffe8296 100644 --- a/src/InstagramScraper/Instagram.php +++ b/src/InstagramScraper/Instagram.php @@ -38,7 +38,7 @@ class Instagram const HTTP_BAD_REQUEST = 400; const MAX_COMMENTS_PER_REQUEST = 300; - const MAX_LIKES_PER_REQUEST = 300; + const MAX_LIKES_PER_REQUEST = 50; const PAGING_TIME_LIMIT_SEC = 1800; // 30 mins time limit on operations that require multiple requests const PAGING_DELAY_MINIMUM_MICROSEC = 1000000; // 1 sec min delay to simulate browser const PAGING_DELAY_MAXIMUM_MICROSEC = 3000000; // 3 sec max delay to simulate browser @@ -1241,7 +1241,7 @@ public function getMediaLikesByCode($code, $count = 10, $maxId = null) $likes = []; $index = 0; $hasPrevious = true; - while ($hasPrevious && $index < $count) { + while ($index < $count) { if ($remain > self::MAX_LIKES_PER_REQUEST) { $numberOfLikesToRetreive = self::MAX_LIKES_PER_REQUEST; $remain -= self::MAX_LIKES_PER_REQUEST; From 73e2d82b3fcdb122e97c28cd3181d2f3f2d1f233 Mon Sep 17 00:00:00 2001 From: Xeus Date: Wed, 8 Jun 2022 07:56:35 +0100 Subject: [PATCH 2/2] get Media Likes 50 count resolved and example file added --- examples/getMediaLikes.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/getMediaLikes.php diff --git a/examples/getMediaLikes.php b/examples/getMediaLikes.php new file mode 100644 index 00000000..44fcdfea --- /dev/null +++ b/examples/getMediaLikes.php @@ -0,0 +1,17 @@ +login(); + +// Get media likes by shortcode +$likes = $instagram->getMediaLikesByCode('CeExu4aD9RC',100, ''); +$like = $likes[0]; +echo "Liker info: \n"; +echo "Username: {$like['username']}\n"; +echo "Full Name: {$like['fullName']}\n"; + + +