
I have a piece of code that checks the youtube embed code in this format: My PHP code looks like this now:
//Check Embed Code
$embedCode = $postData['embedCode'];
/*if(isset($matches[1]))
{*/
preg_match('/<param (.*)">/i', $embedCode, $matches);
if(isset($matches[1]))
{
if(str_replace('movie','as',$matches[1]))
{
$val=explode('>', $matches[1]);
$str=str_replace('name','',$val[0]);
$str=str_replace('=','',$str);
$str=str_replace('"','',$str);
$str=str_replace('value','',$str);
$str=str_replace('movie','',$str);
$str=str_replace('http://www.youtube.com/v/','',$str);
$str=trim($str);
$all=$this->GetYouTubeVideoURL($str);
// GET MEDIA URL
$all_infos=$this->GrabYouTube("http://www.youtube.com/watch?v=$str"); //GET THUMBNAIL URL
$postData['youtube_video_id'] = $all_infos['youtube_video_id'];
$postData['image_url'] = $all_infos['thumbnail_url'];
} else {
$mainframe->enqueueMessage(JText::_('EMBED CODE ERROR'), 'error');
$isValid = false;
}
} else {
$mainframe->enqueueMessage(JText::_('EMBED CODE ERROR'), 'error');
$isValid = false;
}
/*} else {
$mainframe->enqueueMessage(JText::_('EMBED CODE ERROR'), 'error');
$isValid = false;
}*/
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.