Twitter search via Ruby

Thanks to http://www.instantmessagingplanet.com/public/article.php/3800716/Create-a-Twitter-Mood-Graph-With-Ruby.htm, I finally have a twitter search feed working.

 

The link shows how to generate a graph based on tweets, which maybe helpful later. What my requirement was is to show the most recent 10 tweets based on a few keywords. Here’s how I did it:

 

1. Don’t install the twitter gem. It’ll lead you down an oAuth rabbit hole that you don’t really need.

2. In your controller, create a twitter_search definition:

https://gist.github.com/720600

3. Also in your controller index, perform the twitter search:

https://gist.github.com/720604

4. In your view, create a table to display the results:

https://gist.github.com/720606

 

The CGI::unescapeHTML gets rid of the nasty &lt marks. The auto_link detects http[s]://—- strings and makes them an html link. 

Next step is to make it auto-update.

Leave a Reply

Powered by WordPress.com.

Up ↑

Discover more from Ctrl Alt Dad

Subscribe now to keep reading and get access to the full archive.

Continue reading