<?php
function curl_get_contents($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$feed = curl_get_contents("https://www.youtube.com/feeds/videos.xml?channel_id=UCXPaWPHprQSlUUQ8--Ip9cg");
$xml = new SimpleXmlElement($feed);
$count = count($xml->entry);
$url = $xml->entry[0]->link->attributes();
$videourl = explode("&",$url['href']);
$video = str_replace("https://www.youtube.com/watch?v=","",$videourl[0]);
?>