Posted By

richerimage on 09/02/10


Tagged

wordpress twitter thesis


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

laurentzziu
fjarrett


Display your latrest tweets in wordpress


 / Published in: PHP
 

  1. <?php
  2. $username = "TwitterUsername"; // Your twitter username.
  3. $prefix = ""; // Prefix – some text you want displayed before your latest tweet.
  4. $suffix = ""; // Suffix – some text you want display after your latest tweet.
  5. $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
  6.  
  7. function parse_feed($feed) {
  8. $stepOne = explode("<content type=\"html\">", $feed);
  9. $stepTwo = explode("</content>", $stepOne[1]);
  10. $tweet = $stepTwo[0];
  11. $tweet = str_replace("&lt;", "<", $tweet);
  12. $tweet = str_replace("&gt;", ">", $tweet);
  13. return $tweet;
  14. }
  15.  
  16. $twitterFeed = file_get_contents($feed);
  17. echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
  18. ?>

Report this snippet  

You need to login to post a comment.