Posted By

laurentzziu on 11/15/10


Tagged

wordpress entry last twitter


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Grow


Wordpress Last Twitter Entry


 / Published in: PHP
 

  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  

You need to login to post a comment.