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)
Kudos goes to this post for starting me off:
There’s probably an easier way of doing this – so I’m interested in any feedback
Here it is in action: