0

I'm trying to get channel details from a single video on YouTube through their API using php and also the details from the channel.

My code:

private function getYoutubePosts(){
    $timelines = array();

    for ($a = 0; $a < count($this->youtube_sources['users']); ++$a) {

        //ChannelId
        $channelId = false;
        if (strlen($this->youtube_sources['users'][$a]) == '24') {
            $channelId = $this->youtube_sources['users'][$a];
        } else {
            //Get the channelId
            $channel_info = $this->curlCall('https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername='.$this->youtube_sources['users'][$a].'&maxResults=1&fields=items%2Fid&key='.$this->youtube_sources['app_secret']);
            $channelId = $channel_info->items[0]->id;
        }
        //Videos
        if ($channelId) {
            $user_posts = $this->curlCall('https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&order=date&channelId='.$channelId.'&key='.$this->youtube_sources['app_secret']);
            if (isset($user_posts->items)) {
                array_push($timelines, $user_posts->items);

            }
        }  
    }

    return $timelines;

Getting the data. What should I amend, so I could get also the channel thumbnail?

    for ($i = 0; $i < count($youtube_timelines); ++$i) {
            $timeline = $youtube_timelines[$i];
            if ($a < count($timeline)) {
                $post = $timeline[$a];
                array_push($blended_timelines, array(
                        'source' => 'youtube',
                        'username' => $post->snippet->channelTitle,
                        'id' => $post->id->videoId,
                        'link' => 'https://www.youtube.com/watch?v='.$post->id->videoId,
                        'timestamp' => (int) strtotime($post->snippet->publishedAt),
                        'created_time' => date('d M Y', strtotime($post->snippet->publishedAt)),
                        'text' => $post->snippet->description,
                        'image' => $post->snippet->thumbnails->high->url,

                        'author_picture' => $???,



                        )

Already read https://developers.google.com/youtube/v3/docs/videos/list & https://developers.google.com/youtube/v3/docs/channels/list several times.

I would like to get also the channelId thumbnail" to display. Do I miss and or overlook something?

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • Hi and welcome to Stack Overflow! :) It would be very helpful if you could formulate a clear question which the community can then help you with. An example of what is wrong is also helpful. – deiga Nov 14 '17 at 23:27
  • Thanks deiga & @Ilja It's similair to this question: https://stackoverflow.com/questions/18280636/getting-youtube-channel-profile-picture-with-channelid I'm getting the api-info from the video, buit would like to request at the same time the channeldetails from the video, so I can retrieve the channel thumbnail – WieisDennis Nov 16 '17 at 22:57
  • Anybody with a solution? – WieisDennis Nov 20 '17 at 18:27

0 Answers0