Skip to content

Commit

Permalink
getStoryByUrl Example (#949)
Browse files Browse the repository at this point in the history
* getStoryByUrl Example

* Update getUserStoryByUrl.php
  • Loading branch information
hossinasaadi authored Aug 18, 2021
1 parent 051dbf5 commit 7ab4d4d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/getUserStoryByUrl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Phpfastcache\Helper\Psr16Adapter;

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

function getStoryByUrl($instagram, $url)
{
$username = explode("/", $url)[4];
$id = explode("/", $url)[5];
$account = $instagram->getAccount($username);
$profile = $instagram->getStories([$account->getId()])[0];
$stories = $profile->getStories();
foreach ($stories as $story) {
if ($story->getId() == $id) {
return $story;
}
}
}


$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();

$story = getStoryByUrl($instagram, "https://www.instagram.com/stories/hossinasaadi/2642429697467772762/");
print_r($story);

0 comments on commit 7ab4d4d

Please sign in to comment.