Programming Language PHP

Namespace Instagram\Model

Class MediaDetailed

Total Examples 2

2 code examples of PHP Instagram\Model\MediaDetailed extracted from open source projects

Was this example useful?
0
                                                    /**
     * @return MediaDetailed
     * @throws InstagramFetchException
     */
    private function mediaDetailedCarouselHydrator(MediaDetailed $media, \StdClass $node): Media
    {
        $scItems = [];
        foreach ($node->carousel_media as $key => $item) {
            $scItem = new MediaDetailed();
            $scItem->setId((int) $item->pk);
            $scItem->setShortCode($node->code);
            $scItem->setHeight($item->original_height);
            $scItem->setWidth($item->original_width);
            $scItem->setTypeName($this->getTypeName($item->media_type));
            $scItem->setDisplayResources($item->image_versions2->candidates);

            $scItem->setVideo($this->isVideo($node));

            if (property_exists($item, 'video_versions')) {
                foreach ($item->video_versions as $video) {
                    if ($video->type == 101) {
                        $videoSrc = $video->url;
                    }
                }
                $scItem->setVideoUrl($videoSrc ?? null);
            }

            $scItems[] = $scItem;

            if ($key == 0) {
                $media->setDisplayResources($item->image_versions2->candidates);
            }
        }

        $media->setSideCarItems($scItems);

        return $media;
    }
                                            
Was this example useful?
0
                                                    /**
     * @return MediaDetailed
     */
    private function mediaDetailedDataHydrator(MediaDetailed $media, \StdClass $node): Media
    {
        $media->setDisplayResources($node->image_versions2->candidates);

        $media->setHeight($node->original_height);
        $media->setWidth($node->original_width);

        if ($this->isVideo($node)) {
            $media->setHasAudio($node->has_audio);
        }

        if (property_exists($node, 'usertags')) {
            $taggedUsers = [];
            foreach ($node->usertags->in as $user) {
                $taggedUsers[] = $user->user;
            }

            $media->setTaggedUsers($taggedUsers);
        }

        return $media;
    }
                                            
MediaDetailed's Other Methods