-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from postaddictme/master
Branches merging
- Loading branch information
Showing
5 changed files
with
143 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password', 'path/to/cache/folder'); | ||
$instagram->login(); | ||
sleep(2); // Delay to mimic user | ||
|
||
$username = 'kevin'; | ||
$followers = []; | ||
$account = $instagram->getAccount($username); | ||
sleep(1); | ||
$followers = $instagram->getFollowing($account->getId(), 1000, 100, true); // Get 1000 followings of 'kevin', 100 a time with random delay between requests | ||
echo '<pre>' . json_encode($followers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</pre>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
function printMediaInfo(\InstagramScraper\Model\Media $media, $padding = '') { | ||
echo "${padding}Id: {$media->getId()}\n"; | ||
echo "${padding}Shotrcode: {$media->getShortCode()}\n"; | ||
echo "${padding}Created at: {$media->getCreatedTime()}\n"; | ||
echo "${padding}Caption: {$media->getCaption()}\n"; | ||
echo "${padding}Number of comments: {$media->getCommentsCount()}\n"; | ||
echo "${padding}Number of likes: {$media->getLikesCount()}\n"; | ||
echo "${padding}Get link: {$media->getLink()}\n"; | ||
echo "${padding}High resolution image: {$media->getImageHighResolutionUrl()}\n"; | ||
echo "${padding}Media type (video/image/sidecar): {$media->getType()}\n"; | ||
} | ||
|
||
// If account is public you can query Instagram without auth | ||
$instagram = new \InstagramScraper\Instagram(); | ||
|
||
// If account is private and you subscribed to it firstly login | ||
$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password', '/path/to/cache/folder'); | ||
$instagram->login(); | ||
|
||
$media = $instagram->getMediaByUrl('https://www.instagram.com/p/BQ0lhTeAYo5'); | ||
echo "Media info:\n"; | ||
printMediaInfo($media); | ||
|
||
$padding = ' '; | ||
echo "Sidecar medias info:\n"; | ||
foreach ($media->getSidecarMedias() as $sidecarMedia) { | ||
printMediaInfo($sidecarMedia, $padding); | ||
echo "\n"; | ||
} | ||
|
||
$account = $media->getOwner(); | ||
echo "Account info:\n"; | ||
echo "Id: {$account->getId()}\n"; | ||
echo "Username: {$account->getUsername()}\n"; | ||
echo "Full name: {$account->getFullName()}\n"; | ||
echo "Profile pic url: {$account->getProfilePicUrl()}\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters