I was working on a project the other day, which needs to buy different videos from different users in YouTube. Thus I do not want to use YouTub API as I need something simpler, and I do not need the feeds from the user.
I found this script which is able to convert the URL to embedded video, and get the youtube thumbnail as well. All these are do able without using any YouTube API.
First, parse in the YouTube URL , which I assign the variable as $url.
Copy and paste the script below and change the width and height accordingly.
$vidparser = parse_url($url);
parse_str($vidparser[query], $query);
$vidid = ($query['v']);
$width=”550″; $height=”350″;
$content = “<div align=\”center\”><object width=\”".$width.”\” height=\”".$height.”\”><param name=\”movie\” value=\”http://www.youtube.com/v/”.$vidid.”&hl=en&fs=1&rel=0\”></param><param name=\”allowFullScreen\” value=\”true\”></param><embed src=\”http://www.youtube.com/v/”.$vidid.”&hl=en&fs=1&rel=0\” type=\”application/x-shockwave-flash\” allowfullscreen=\”true\” width=\”".$width.”\” height=\”".$height.”\”></embed></object></div>”;
echo $content;
To get the YouTube thumbnail, use the same method to apply to the line of code below.



Home