Wordpress Last Twitter Entry


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



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. // Your twitter username.
  4. $username = "TwitterUsername";
  5.  
  6. $prefix = "<h2>My last Tweet</h2>";
  7.  
  8. $suffix = "";
  9.  
  10. $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
  11.  
  12. function parse_feed($feed) {
  13. $stepOne = explode("<content type=\"html\">", $feed);
  14. $stepTwo = explode("</content>", $stepOne[1]);
  15. $tweet = $stepTwo[0];
  16. $tweet = str_replace("&lt;", "<", $tweet);
  17. $tweet = str_replace("&gt;", ">", $tweet);
  18. return $tweet;
  19. }
  20.  
  21. $twitterFeed = file_get_contents($feed);
  22. echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
  23. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.