Youtube xml reader
6
strandedfisherman
This gets the information off youtube when you add a youtube link.
please change the dev_id to your own my is:BnvzCjJ_Bzw
http://www.youtube.com/my_profile_dev
put a link in eg. http://www.youtube.com/watch?v=xOJnKgsWPGw
please change the dev_id to your own my is:BnvzCjJ_Bzw
http://www.youtube.com/my_profile_dev
put a link in eg. http://www.youtube.com/watch?v=xOJnKgsWPGw
//GETS INFO FROM ADRESS EG ?creator=1
$frm_ytstring = "http://www.youtube.com/watch?v=jr3JEwXtudA";
$checkyt = explode(".", $frm_ytstring);//Bad xml parsing
$gotcheckyt = $checkyt[1];
//if ($gotcheckyt == "youtube" ){
//gets vid id
$yt_start = explode("v=",$frm_ytstring,2);
$yt_end = explode("&",$yt_start[1],2);
$gotid = $yt_end[0];
//youtube xml setup
$getinfoytlink = "http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=BnvzCjJ_Bzw&video_id=$gotid";
//this page gets xml info off utube
$yt_xml_pic_string = @file_get_contents($getinfoytlink);
$yt_xml_pic_start = explode("<thumbnail_url>",$yt_xml_pic_string,2);
$yt_xml_pic_end = explode("</thumbnail_url>",$yt_xml_pic_start[1],2);
$yt_pic = $yt_xml_pic_end[0];
echo "piclink:".$yt_pic."<br>";
//echo $yt_pic;
$yt_xml_author_string = @file_get_contents($getinfoytlink);
$yt_xml_author_start = explode("<author>",$yt_xml_author_string,2);
$yt_xml_author_end = explode("</author>",$yt_xml_author_start[1],2);
$yt_author = addslashes($yt_xml_author_end[0]);
echo "author:".$yt_author."<br>";
//echo $yt_author;
$yt_xml_title_string = @file_get_contents($getinfoytlink);
$yt_xml_title_start = explode("<title>",$yt_xml_title_string,2);
$yt_xml_title_end = explode("</title>",$yt_xml_title_start[1],2);
$yt_title = addslashes($yt_xml_title_end[0]);
$yt_title_noslash = $yt_xml_title_end[0];
echo "title:".$yt_title_noslash."<br>";
//echo $yt_title."<br>";
$yt_xml_description_string = @file_get_contents($getinfoytlink);
$yt_xml_description_start = explode("<description>",$yt_xml_description_string,2);
$yt_xml_description_end = explode("</description>",$yt_xml_description_start[1],2);
$yt_description = addslashes($yt_xml_description_end[0]);
echo "description:".$yt_description."<br>";
//echo $yt_description."<br>";
$yt_xml_view_count_string = @file_get_contents($getinfoytlink);
$yt_xml_view_count_start = explode("<view_count>",$yt_xml_view_count_string,2);
$yt_xml_view_count_end = explode("</view_count>",$yt_xml_view_count_start[1],2);
$yt_view_count = $yt_xml_view_count_end[0];
echo "view count:".$yt_view_count."<br>";






preg_match('/v(=|\/)([\w\-]+)/', $frm_ytstring, $gotit);
$gotit = $gotit[2];
On a sidenote, you could also use parse_str() to get the ID.