Reputation: 103
I have experience only in making small simple apps in PHP, Java and ASP.NET. I had no idea what GET, SET etc exactly are and what REST services are. To try to use the Twitter API, I did some reading and got to know (I might be wrong here, because this is what I THINK that I know..) that you can make a GET request like this one: http://api.twitter.com/1/statuses/user_timeline.json
I just need guideline on how can I display ( of a specific account ) number of followers, retweets, tweets, follwing, how the long the account was created, etc by using Ruby on Rails. I am not asking you to give me bread, I'm asking you to tell me what should I do to learn to fish?
Would you please like to tell me where to start? Eitherway, I tried my examples and tutorials but sorry to say that none of them even worked to just authroize my page via twitter.
Upvotes: 0
Views: 1014
Reputation: 471
I recommend using the Twitter API It helps simplify the process.
If you are just setting this up for a single account this part of the twitter docs is useful https://dev.twitter.com/docs/auth/tokens-devtwittercom
As other people will most likely stumble across this, here are my steps to setting up the twitter api for a single user in rails.
Follow twitter documentation above to set up authorization tokens
Gemfile
gem 'twitter'
Create a helper twitter_helper.rb
using environment variables to store your keys
module TwitterHelper
def self.get_client
Twitter::REST::Client.new do |config|
config.consumer_key = ENV["CONSUMER_KEY"]
config.consumer_secret = ENV['CONSUMER_SECRET']
config.access_token = ENV['ACCESS_TOKEN']
config.access_token_secret = ENV['TOKEN_SECRET']
end
end
def get_client
TwitterHelper.client
end
end
Then do something like
client = TwitterHelper.get_client
client.friends.all
to return all friends of the account set up.
Upvotes: 1
Reputation: 2638
I suggest starting out with this online book: Ruby On Rails Tutorial - Michael Hartl
This book covers everything you will need to know to get started including what REST services are and how to setup and install rails.
It might take a few days to go through the entire book but once you do you will know exactly what to do to make your app happen.
Upvotes: 0