PhpTips.im - Everything about php - Download CMS, find tips and tricks, code snippetz, classes and more and more...
Bookmark this page !
   

Articles

    Home » Articles » PHP Snippets » Display your latest tweet on Wordpress without a plug-in
Published on : 15.05.2010 Category : PHP Snippets Viewed : 55 times.

Code:


  1. <?php
  2.  
  3. // Your twitter username.
  4. $username = "TwitterUsername";
  5.  
  6. // Prefix - some text you want displayed before your latest tweet.
  7. // (HTML is OK, but be sure to escape quotes with backslashes: for example href="link.html")
  8. $prefix = "<h2>My last Tweet</h2>";
  9.  
  10. // Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
  11. $suffix = "";
  12.  
  13. $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
  14.  
  15. function parse_feed($feed) {
  16. $stepOne = explode("<content type="html">", $feed);
  17. $stepTwo = explode("</content>", $stepOne[1]);
  18. $tweet = $stepTwo[0];
  19. $tweet = str_replace("&lt;", "<", $tweet);
  20. $tweet = str_replace("&gt;", ">", $tweet);
  21. return $tweet;
  22. }
  23.  
  24. $twitterFeed = file_get_contents($feed);
  25. echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
  26. ?>



Add this article in :

 

There is not yet any comment !



1090 Rating: 0.0/10 (0 votes cast)

 

 Members
Log In !
Email Address :

Password :


Change my passowrd !
Sign Up !
We have : 3 members.
Latest member : albans
 
 Last Posts
 
 Advertising
 
©PhpTips.im 2010
Powered by PikaCMS.
Quick Links :
Home | Browse all articles | Downloads | Terms of Use
RSS RSS 2.0 : Articles | Downloads ATOM : Articles | Downloads