I’ve been searching for a while on how to simply connect a user’s id to their twitter account in my Rails 3 app. I don’t want users to login with twitter, I just want them to be able to connect their twitter account to the Rails app so I can pull in that user’s tweets with a specific hashtag.
I found the following tutorials recommending the twitter_oauth gem:
- http://veerasundaravel.wordpress.com/2010/11/26/twitter-connection-in-rails-using-twitter_oauth-gem/
- http://franciscojsaez.tumblr.com/post/3363794466/connect-your-rails-app-to-twitter
This prior SO question/answer helped a bit and I’ve been watching the Railscasts for OmniAuth. However I’m somewhat confused. Since I’m not logging in with twitter, I’m not sure where to integrate things. Is this handled in the UsersController or do I need to create an AuthenticationsController the way Ryan does in Railscast #235?
Any help would be greatly appreciated!
Looks like you are going about this the wrong way. If you don’t need to log them in through Twitter, and just want to get at their tweets.
Have them pop in their twitter username, then just make an API call to get their tweets with that hashtag.
should return a json object that you can further parse to get what you need.
The documentation for the Twitter search API can be found here:
https://dev.twitter.com/docs/using-search