Display your latrest tweets in wordpress


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.