now available

now available
Want fresh tech tips in your inbox?

Grab a Twitter Status without the Twitter API


Quick and dirty way to grab the users status messages without having to go through the twitter api (not having to authenticate that is). You can grab the RSS feed and indicate the number of statuses returned with the count param. I wrote this function for my blog in PHP. It uses the curl extension so if it's not installed type

apt-get install php5-curl
Otherwise you'll have to use the fsockopen function. Then it's just a matter of parsing the XML and getting at what data you want. I just want one status so I'm accessing the element directly, rather than looping over the returned data set.

function latest_twitter_status_message(){
        // grab the rss feed link from some user, like me and indicate the count in the url
    $host = "http://twitter.com/statuses/user_timeline/11036982.rss?count=1";
    // using curl
    $ch = curl_init($host);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    $doc = new SimpleXmlElement($data, LIBXML_NOCDATA);
    return "{$doc->channel->item[0]->description}";

Tagged w/ #curl #function #rss #twitter #xmlphp

Apps I've Built

XPath Expression Editor
Practice and improve your XPath skills with XPath Editor
Click to buy on the App Store
Photo Location Changer
Easily change the location on your photos and videos
Click here for more info about the app
Photo Date Changer
Easily change the dates and times on your photos and videos
Click here for more info about the app
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app