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.

<php
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);
	curl_close($ch);
	$doc = new SimpleXmlElement($data, LIBXML_NOCDATA);
	return "{$doc->channel->item[0]->description}";
}
19 Nov 2009, 1:59pm
Business:
by

leave a comment

Adding RSS Graffiti to my Facebook Page

I added the RSS Graffiti application to my Facebook account. It’s a nifty app that lets you add any valid Rss/Atom feed to your profile (includes publishing to your wall) and to your pages.

Installing Feedzirra RSS Parser on Ubuntu 8

I recently watched a RailsCasts episode (http://railscasts.com/episodes/168-feed-parsing) on parsing and persisting RSS feeds using Feedzirra. It took a little setting up on Ubuntu because it relies on some libraries that aren’t included with Ubuntu > 8.

The gem will fail right off the bat

gem sources -a http://gems.github.com # if you haven't already
gem install pauldix-feedzirra

Here is what I needed before I could install the gem

apt-get install libcurl3
apt-get install libxml2 libxml2-dev
apt-get install libxslt1-dev

Then go ahead and

gem install pauldix-feedzirra

Here are some other useful resources

http://github.com/pauldix/feedzirra/tree/master

http://ruby.zigzo.com/2009/02/15/feedzirra-installation-errors/