Posted By

marshall on 03/17/11


Tagged

rss xml tumblr


Versions (?)

SimpleXML and PHP Error Handling - Tumblr RSS Example


 / Published in: PHP
 

URL: http://marshallim.posterous.com/simplexml-and-php-error-handling-tumblr-rss-e

  1. <ul>
  2.  
  3. <?php
  4. $rss = @simplexml_load_file('http://thedailywhat.tumblr.com/rss');
  5. if ($rss) {
  6. $i = 0;
  7. foreach ($rss->channel->item as $item) {
  8. if (++$i > 7) {
  9. // stop after 7 items
  10. break;
  11. }
  12. echo "<li><a href='" . $item->link . "'>" . $item->title . "</a></li>\n";
  13. }
  14. } else {
  15. echo "Tumblr is down.";
  16. }
  17. ?>
  18.  
  19. </ul>

Report this snippet  

You need to login to post a comment.