WhatsApp Chat
Send us a message today and we will contact you as soon as possible.
UPDATE: As of Aug 31st 2010 this method will no longer work. Read an improved way of doing it here: Improved way of getting last Twitter status using SimplePie

Well I figured it would be easy to do – so why has it taken me most of the afternoon to figure it out?!

I was looking for a way to simply get the text of my last Twitter “tweet” and then use the text within my site somewhere.

Ok I shall fess up – the reason I really wanted to know how to do this was for a client who needed to be able to update one line of text on his website, so he can have a lovely ticker tape banner across his site (I kid you not!) – but he didn’t have the budget (or technical know how) to have & use a CMS for his web site – anyway it would be like using a hammer to crack a nut, right?

So I though maybe if I could use the last Tweet he posted in his Twitter account it might be a nice way of getting him to write more on Twitter (great marketing potential yadda yadda…) and a natty way of giving him a mini CMS!

So after a lot of searching – and finding some very complicated solutions doing all manners of things with the Twitter API (which is very mysteriously documented if you ask me) I came up with the following solution – a PHP function that returns the last tweet.

(Note the XML parser I use is only available in PHP5)

status[0]->text;

}

echo twitterCapture();

?>


Kudos goes to this post for starting me off:
http://blarnee.blogspot.com/2009/09/this-is-test.html

There’s probably an easier way of doing this – so I’m interested in any feedback

Here it is in action:
http://www.kineticpulse.co.uk/twitter5.php5

2 responses

  1. Thanks for he comment – but for some reason on my set up this doesn't return any thing.
    I don't think it likes the "simplexml_load_file()" function.
    So I'll stick to the above method until I figure out whats happening
    :>