Reputation: 3390
I'm using the twitter gem located here... http://rubydoc.info/gems/twitter/2.0.2
I'm trying to use a method that requires authentication... Twitter.home_timeline
The rdoc readme file at http://rubydoc.info/gems/twitter/2.0.2/file/README.md states...
Certain methods require authentication. To get your Twitter OAuth credentials, register an app at http://dev.twitter.com/apps
I have this file configured and set up...
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
Now what I want, is for a user to come to my app, be able to enter their screen name and password and then see a display of their live stream and all sorts of cool twitter data on their user.
Please help... how do I do this? What method do I use to pass the website visitors username and password?
...ah yes, I am a rails noob so please be gentle.
Upvotes: 0
Views: 881
Reputation: 46713
I think you are misunderstanding how this all works. The user never gives you their Twitter username/password. Here's what happens:
OmniAuth
.. see this RailsCast for more info: http://railscasts.com/episodes/241-simple-omniauth)Now that you went through those steps and you have the user's necessary access keys (i.e. the token and token secret), you can get their timeline info:
# Set all necessary auth info
Twitter.consumer_key = TWITTER_CONSUMER_KEY_GOES_HERE
Twitter.consumer_secret = TWITTER_CONSUMER_SECRET_GOES_HERE
Twitter.oauth_token = current_user.token
Twitter.oauth_token_secret = current_user.token_secret
# Get the most recent tweets from the Timeline
most_recent_tweets = Twitter.home_timeline
Upvotes: 5