Nick
Nick

Reputation: 35

How do I add a twitter search feed to my Ruby on Rails application?

I want to add a twitter feed for a specific keyword search to my rails application. Where should I start?

Upvotes: 1

Views: 1963

Answers (3)

Amber
Amber

Reputation: 526633

You might start with one of the Twitter API libraries written for Ruby.

Upvotes: 3

Jonathon Horsman
Jonathon Horsman

Reputation: 2333

We download and store the tweets in a local database. I recently wrote a blog post about how I achieved this:

http://www.arctickiwi.com/blog/16-download-you-twitter-feed-using-ruby-on-rails-with-oauth

You can then use will_paginate to handle your pagination and go back as far as you want.

Upvotes: 0

ryanb
ryanb

Reputation: 16287

You may want to consider grabbing the RSS feed for the search and parsing that. I show that in Railscasts episode 168. If you need something more fancy the API is the way to go as Dav mentioned.

But whichever solution you choose, it's important to cache the search results locally on your end. This way your site isn't hitting Twitter every time someone goes to the page. This improves performance and will make your site more stable (not breaking when twitter breaks). You can have the cache auto-update every 10 minutes (or whatever fits) using a cron task.

Upvotes: 1

Related Questions