function getXML($channel_id){
$url=sprintf('https://www.youtube.com/feeds/videos.xml?channel_id=%s', $channel_id);
$xml="";
$xml = @simplexml_load_file($url);
if ($xml==""){
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($curl);
$xml = simplexml_load_string($data);
}
return $xml;
}
$channel_id = "UCMQbo8SZEGJvPdpD8skSFYg";
if ($channel_id!=""){
$xml = getXML($channel_id);
if ($xml->entry[0] && !empty($xml->entry[0]->children('yt', true)->videoId[0])){
$id = $xml->entry[0]->children('yt', true)->videoId[0];
}
}
if ($channel_id != "" && $id != ""){
echo '<iframe src="https://www.youtube.com/embed/'.$id.'" frameborder="0" allowfullscreen></iframe>';
}