This can be done in following way.
FIrstly, in the coding you need to setup and put youtube api key.
Secondly, use the channel id from where you want to bring the youtube videos.
$API_key = 'youtube-api-key'; $channelID = 'channel-id'; $maxResults = 10; $videoList = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$channelID.'&maxResults='.$maxResults.'&key='.$API_key.'')); foreach($videoList->items as $video){ //Embed video if(isset($video->id->videoId)){ echo '< iframe src="https://www.youtube.com/embed/'.$video->id->videoId.'" width="280" height="150" frameborder="0" allowfullscreen="allowfullscreen">< / iframe >'. $video->snippet->title;}}
Note: In the api reponse you will be also getting following propertise that you can use depending on client requirements.
- Publish Date – $video->snippet->publishedAt
- Channel ID – $video->snippet->channelId
- Channel Title – $video->snippet->channelTitle
- Title – $video->snippet->title
- Description – $video->snippet->description
- Thumbnail URL – $video->snippet->thumbnails->default->url (default size)
- Thumbnail URL – $video->snippet->thumbnails->medium->url (medium size)
- Thumbnail URL – $video->snippet->thumbnails->high->url (large size)