Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get Media Likes 50 count resolved and example file added #1073

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/getMediaLikes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
use Phpfastcache\Helper\Psr16Adapter;

require __DIR__ . '/../vendor/autoload.php';

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->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";



4 changes: 2 additions & 2 deletions src/InstagramScraper/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down