Showing your last “twit” using php
While editing my blog theme, I decided to add my last thoughts in twitter to the website. Came with a very simple php code that will get the information from the last twitter post and show it as a text line, so you can add in anywhere you want.
This is the code:
<?php
preg_match('#<text>(.*)#',file_get_contents('http://twitter.com/statuses/user_timeline/username.xml?count=1'), $matches);
echo $matches[0]
?>
preg_match('#<text>(.*)#',file_get_contents('http://twitter.com/statuses/user_timeline/username.xml?count=1'), $matches);
echo $matches[0]
?>
Of course, remember to change username for your own.
2 Comments
Leave a comment
Top Posts
HowTo: Blinking LEDs
HowTo: External Winamp Control
Temperature Sensor + Arduino
10 Things To Do Just After Installing Ubuntu 7.10
How To Make Your Iphone Battery Last Longer
Recent Comments
- (Rob Gleason): Hey guys this is an awesome pr
- (Silviu): Is there a problem if I use 1k
- (ET): Hi :) Great project. THX. I'm
- (Terry): Please add http://www.ushareim
- (Judah): Hey, I know this is 7 years on
- (DanielAndrade): Hello Gilbert, what you could
- (Gilbert): Hi there. I am thinking abo
- (Dev): Thanks for this, followed your
- (Alex): Hey, sounds like there is some
- (Paul K.): Just a heads up - if you cut a
Status
Posts: 193
Comments:1476
Comments/Posts: 8
I Support

I support the Open Source Hardware Definition v1.0
Proudly Hosted By





Hi Daniel- found you through Paul Stamatiou’s site, and since I don’t use wordpress (and thus no wordpress plugin goodness), I’m attempting your twitter method, as it appears to be platform independent. However, I put it in a php file on my site, and it just prints out the php file, not the tweet.
php works fine on the site, though.
the link is http://www.creativehedgehog.com/twitter.php
yes I’m dumb… I removed the space between < and ? at the php, and now it doesn’t just print the contents of the php file. It doesn’t show the twitter info either though.