Skip to content

Commit

Permalink
Add direct link in highlight folder
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrimaud committed Sep 21, 2021
1 parent 74ebf5f commit 3f82d9e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/story-highlights.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

$storyHighlights = $api->getStoryHighlightsFolder($profile->getId());
sleep(1);
dump($storyHighlights);

foreach ($storyHighlights->getFolders() as $folder) {
$folder = $api->getStoriesOfHighlightsFolder($folder);
Expand Down
3 changes: 2 additions & 1 deletion src/Instagram/Hydrator/StoryHighlightsHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public function hydrateFolders(\StdClass $data): void
foreach ($data->edges as $highLight) {
$folder = new StoryHighlightsFolder();

$folder->setId((int)$highLight->node->id);
$folder->setId((int) $highLight->node->id);
$folder->setName($highLight->node->title);
$folder->setCover($highLight->node->cover_media_cropped_thumbnail->url);
$folder->setUrl('https://www.instagram.com/s/' . base64_encode('highlight:' . $highLight->node->id));

$this->highlights->addFolder($folder);
}
Expand Down
21 changes: 21 additions & 0 deletions src/Instagram/Model/StoryHighlightsFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class StoryHighlightsFolder
*/
private $cover;

/**
* @var string
*/
private $url;

/**
* @var array
*/
Expand Down Expand Up @@ -94,4 +99,20 @@ public function orderStories(): void
{
$this->stories = array_reverse($this->stories);
}

/**
* @return string
*/
public function getUrl(): string
{
return $this->url;
}

/**
* @param string $url
*/
public function setUrl(string $url): void
{
$this->url = $url;
}
}
1 change: 1 addition & 0 deletions tests/StoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function testHighlightsStoriesFetch()
$this->assertSame('STORY', $folder->getName());
$this->assertSame('https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/s150x150/94263786_546583649377430_3277795491247917640_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_ohc=D6Img4muLocAX_bsIlI&oh=eeeec52698961ee00a070d3e210f532d&oe=5EF1ACCB', $folder->getCover());
$this->assertCount(33, $folder->getStories());
$this->assertSame('https://www.instagram.com/s/aGlnaGxpZ2h0OjE4MTM3NTkwNDQ0MDE0MDI0', $folder->getUrl());

$api->logout('username');
}
Expand Down

0 comments on commit 3f82d9e

Please sign in to comment.