|
TECHNOLOGY
![]() AN OPEN SOURCE WRAPPER FOR YOUTUBE'S API
Php5tube is a free, open source class written by Debugged Interactive Designs in PHP5 to act as a wrapper for Youtube's API. Methods process the response XML and return a friendly array of data to make development simple and intuitive.
Step 1: Download and unzip archive
The class is hosted at http://www.debuggeddesigns.com/open-source-projects/php5tube/code
NOTE: A slightly modified version can be found here. All changes are black box and should not affect your external code. For a list of alterations read the change log at the top of Php5tube.php.
Step 2: Read the documentation
The doc is hosted at http://www.debuggeddesigns.com/open-source-projects/php5tube/docs
Step 3: Use the provided test script
Filename: /php5tube/test.php
<?php
//get or create youtube username if( isset($_GET['user']) ){$youtube_user = $_GET['user'];} else {$youtube_user = 'rickrolled';} //create phptube object and get videos include_once("Php5tube.php"); $php5tube = new Php5tube('Video','User','Comment'); $videos = $php5tube->getUserVideos($youtube_user); //dump array of views //var_dump($videos); ?> <html> <head><title></title></head> <body> <table cellpadding="0" cellspacing="0"> <?php foreach($videos as $video) { ?> <tr><td> <div style="padding:2px;"><img src="<?php echo $video['Video']['thumbnail_url1']; ?>"> </div> <div style="padding:2px;"><img src="<?php echo $video['Video']['thumbnail_url2']; ?>"> </div> <div style="padding:2px;"><img src="<?php echo $video['Video']['thumbnail_url3']; ?>"> </div> </td><td> <div style="padding:10px;"> <a href="http://www.youtube.com/v/<?php echo $video['Video']['youtube_id']; ?>"> <img src="<?php echo $video['Video']['thumbnail_url4']; ?>"> </a> </div> </td> <td> <div style="font-size:16pt;"><?php echo $video['Video']['title']; ?></div> <div><b>Category</b> = <?php echo $video['Video']['category']; ?></div> <div><b>Tags</b> = <?php echo $video['Video']['keywords']; ?></div> <div><b>Description</b> = <?php echo $video['Video']['description']; ?></div> <div><b>Views</b> = <?php echo $video['Video']['view_count']; ?> times</div> <div><b>Marked as favorite</b> = <?php echo $video['Video']['favorite_count']; ?> times</div> </td></tr> <?php } ?> </table> </body> </html> Step 4: Try out the test script
Upload the files 'Php5tube.php' and 'test.php' into the same directory ("php5tube" in this example) on a web server with PHP 5+ running. Then open a browser and visit www.yourdomain.com/php5tube/test.php to see what Php5tube can do.
COMMENTS (displaying 1 comment) 1. Posted on November 4, 2008 by ahsn2020 hi forphp group POST (leave a comment) |
POPULAR BLOG TAGS
launch
science
captcha
spam
php5tube
usort
class
color
debuggeddesigns
drum machines
1984
bakery
ableton
code
gmail
published
charlie
youtube
privacy
rot13
as
orwell
open source
skateboard
defcon
sports
security
google
release
mbta
brain
mit
quicksilver
encryption
general
boston
snowboard
whoami
php
regular expressions
geek
magazine
cakephp
germans
mailto
trice
email
hobnox
flash
routes
|