|
WikiPage
IntroductionSimple Class Youtube, is a simple PHP class for obtaining information from a video on YouTube, through simple methods that provide the class. DetailsWith this class, you can obtain:
ExamplesInstantiationDo you have two alternatives to instance the Simple Class Youtube With the complete youtube url: http://www.youtube.com/watch?v=5ocq6_3-nEw $url = 'http://www.youtube.com/watch?v=5ocq6_3-nEw'; $youtube = new Youtube($url); Or with specific ID video: 5ocq6_3-nEw $id = '5ocq6_3-nEw'; $youtube = new Youtube($id); Valid VideoIf URL is incorrect or ID is invalid, this method valid(); return false. var_dump($youtube->valid()); //true in this example. TitleFor get video title, only use getTitle(); methods. echo $youtube->getTitle(); //The Story of Linux: Commemorating 20 Years of the Linux Operating System PublishedFor get video published time, use getPublished(); echo $youtube->getPublished(); //2011-03-31T20:12:23.000Z UpdatedFor get video updated time, use getUpdated(); echo $youtube->getUpdated(); //2011-08-01T05:17:51.000Z CategoryFor get video example category, use getCategory(); echo $youtube->getCategory(); //Science & Technology TagsFor get video example tags, use getTags(); echo var_dump($youtube->getTags()); //Return array with a tags ContentFor get video example content (HTML provides Youtube), use getContent(); echo $youtube->getContent(); //Return HTML with video content DescriptionFor get video example description, use getDescription(); echo $youtube->getDescription(); //Celebrate the 20th Anniversary of Linux with us. Watch the Story of Linux to remember - or learn for the first time - how Linux disrupted a market and has begun to change the world. Do you see yourself in its story? LinkFor get video example Url, use getUrl(); echo $youtube->getUrl(); //http://www.youtube.com/watch?v=5ocq6_3-nEw ImageFor get video example Image, use getUrl(TYPE); TYPE = [ default | 0 | 1 | 2 | 3 ] echo $youtube->getImageUrl('default');
//http://i.ytimg.com/vi/5ocq6_3-nEw/default.jpgAuthor DataAuthor NameFor get video example username, use getAuthorName(); echo $youtube->getAuthorName(); //TheLinuxFoundation Author UrlFor get video example user url, use getAuthorUrl(); echo $youtube->getAuthorUrl(); //http://www.youtube.com/user/TheLinuxFoundation Author UriFor get video example user url, use getAuthorUri(); echo $youtube->getAuthorUri(); //http://gdata.youtube.com/feeds/users/thelinuxfoundation VideoFor get video example code embeb, use getEmbeb(OPTIONS); To view the parameters allowed, please see http://code.google.com/apis/youtube/player_parameters.html $options = array('autoplay' => 1);
echo $youtube->getEmbeb($options);
//<iframe class="youtube-player" type="text/html" width="425" height="349" src="http://www.youtube.com/embed/5ocq6_3-nEw?autoplay=1"></iframe>Other example... $options = array('autoplay' => 1, 'width' => 853, 'height' => 510, 'hd' => 1);
echo $youtube->getEmbeb($options);
//<iframe class="youtube-player" type="text/html" width="853" height="510" src="http://www.youtube.com/embed/5ocq6_3-nEw?autoplay=1&hd=1"></iframe>In Progress... |
Super Cool. Gracias