Twitter RSS Feed


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. print "<br />";
  2.  
  3. $feed = file_get_contents('http://twitter.com/statuses/user_timeline/25556798.rss');
  4. $xml = new SimpleXMLElement($feed);
  5. $i = 0;
  6. foreach ($xml->channel->item as $feed) {
  7. $patterns = array();
  8. $patterns[0] = '/00:00:00/';
  9. $patterns[1] = '/-0500/';
  10. $patterns[2] = '/-0400/';
  11. $patterns[3] = '/ParadigmRoofing:/';
  12. $replacements = array();
  13. $replacements[0] = ' ';
  14. $replacements[1] = ' ';
  15. $replacements[2] = ' ';
  16. $replacements[3] = ' ';
  17.  
  18. $cleanedtitle = preg_replace($patterns, $replacements, $feed->title);
  19.  
  20.  
  21. echo '<h2><a href=' . $feed->link . '>' . $cleanedtitle . '</a></h2>' . '<br />';
  22.  
  23.  
  24.  
  25. $i++;
  26.  
  27. if($i == 3) {
  28.  
  29. break;
  30. }
  31.  
  32. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.