Skip to content

Commit

Permalink
Add more properties in hightlights folder
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrimaud committed Sep 21, 2021
1 parent 3f82d9e commit bb2d1d4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Instagram/Hydrator/StoryHighlightsHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ public function hydrateFolders(\StdClass $data): void
foreach ($data->edges as $highLight) {
$folder = new StoryHighlightsFolder();

$url = 'https://www.instagram.com/s/' . base64_encode('highlight:' . $highLight->node->id);

$folder->setId((int) $highLight->node->id);
$folder->setUserId((int) $highLight->node->owner->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));
$folder->setUrl($url);
$folder->setSharableUrl(
$url . '?story_media_id=' . $highLight->node->id . '_' . $highLight->node->owner->id .
'&utm_medium=copy_link'
);

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

/**
* @var int
*/
private $userId;

/**
* @var string
*/
Expand All @@ -26,6 +31,11 @@ class StoryHighlightsFolder
*/
private $url;

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

/**
* @var array
*/
Expand Down Expand Up @@ -115,4 +125,36 @@ public function setUrl(string $url): void
{
$this->url = $url;
}

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

/**
* @param string $sharableUrl
*/
public function setSharableUrl(string $sharableUrl): void
{
$this->sharableUrl = $sharableUrl;
}

/**
* @return int
*/
public function getUserId(): int
{
return $this->userId;
}

/**
* @param int $userId
*/
public function setUserId(int $userId): void
{
$this->userId = $userId;
}
}
2 changes: 2 additions & 0 deletions tests/StoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ public function testHighlightsStoriesFetch()
$folder = $api->getStoriesOfHighlightsFolder($storyHighlights->getFolders()[0]);

$this->assertSame(18137590444014024, $folder->getId());
$this->assertSame(5670185369, $folder->getUserId());
$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());
$this->assertSame('https://www.instagram.com/s/aGlnaGxpZ2h0OjE4MTM3NTkwNDQ0MDE0MDI0?story_media_id=18137590444014024_5670185369&utm_medium=copy_link', $folder->getSharableUrl());

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

0 comments on commit bb2d1d4

Please sign in to comment.