Created
October 30, 2019 17:37
-
-
Save farvisun/427094e67de9b5f706c1fbb05a6c6afe to your computer and use it in GitHub Desktop.
Download Instagram Stories without mark them as seen :)))
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
<?php | |
/** | |
you should this before run this code | |
composer require mgp25/instagram-php | |
*/ | |
require_once __DIR__ . '/vendor/autoload.php'; | |
$ig = new \InstagramAPI\Instagram(false, false); | |
try { | |
$account = $ig->login('YOUR USERNAME', 'YOUR PASSWORD'); | |
$stories = $ig->story->getReelsTrayFeed(); | |
$folderPath = __DIR__ . '/stories/' . date('Y-m-d') . '/'; | |
if (!file_exists($folderPath)) { | |
mkdir($folderPath, 0777, true); | |
echo 'start to create folder : ' . PHP_EOL; | |
} | |
echo "Start to fetch" . PHP_EOL; | |
$totalStories = count($stories->getTray()); | |
foreach ($stories->getTray() as $i => $story) { | |
$data = $ig->story->getUserReelMediaFeed($story->getUser()->getPk()); | |
echo $i . '/' . $totalStories . " Get data from user : " . $story->getUser()->getUsername() . PHP_EOL; | |
$total = count($data->getItems()); | |
foreach ($data->getItems() as $index => $item) { | |
file_put_contents($folderPath . $data->getUser()->getUsername() . '_' . $index . '.jpg', | |
file_get_contents($item->getImageVersions2()->getCandidates()[0]->getUrl())); | |
echo '[' . $index . '/' . $total . '] download image from ' . $data->getUser()->getUsername() . PHP_EOL; | |
} | |
} | |
echo base64_decode('2KLYriDYotiuINin2LIg2KfYr9mFINmB2YjYttmI2YQgOikpKSkpKQ==') . PHP_EOL; | |
} catch (\Exception $exception) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment