Posted By

jaytee on 03/03/08


Tagged

rss YouTube


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

adix
rchk
tallalex85
LordBumpet


Display a user's YouTube videos


 / Published in: PHP
 

Uses the Magpie RSS library (http://magpierss.sourceforge.net/). I suppose I should be using the GData API, but this was a quicker solution for me.

  1. require_once('magpierss/rss_fetch.inc');
  2. $rss = fetch_rss("http://www.youtube.com/rss/user/$username/videos.rss");
  3. foreach ($rss->items as $item) {
  4. preg_match('/http:\/\/(.*)default.jpg/',$item['description'],$matches);
  5. $thumb = $matches[0];
  6. $title = $item['title'];
  7. $link = $item['link'];
  8. $date = date("n/d/Y",strtotime($item['pubdate']));
  9. ?>
  10. <div class="video">
  11. <a href="<?php echo $link; ?>"><img src="<?php echo $thumb; ?>" /></a><br />
  12. <strong><?php echo $title; ?></strong><br />
  13. posted on <?php echo $date; ?>
  14. </div>
  15. <?php
  16. }
  17. ?>

Report this snippet  

You need to login to post a comment.