How to Fetch all Channel Youtube Videos with PHP

How to retrieve all youtube videos from a youtube channel. Get the latest and all videos from a youtube channel via php youtube api.

This is a short tutorial snippet on how to fetch via YouTube API's a channels videos. You first have to create an API Key in order to be granted into YouTube API Data. 

Getting Started on YouTube API: https://developers.google.com/youtube/v3/getting-started  

//Get videos from channel by YouTube Data API
$API_key    = 'API_KEY';
$channelID  = 'CHANNEL_ID';
$maxResults = 50;

$videoList = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$channelID.'&maxResults='.$maxResults.'&key='.$API_key.''), true);

echo "<pre>";
print_r($videoList);
echo "</pre>";