Install the gem

Proceed to install the required gem with gem install twitter as indicated at https://github.com/sferik/twitter.

Sample code

1
2
3
4
5
6
7
8
9
10
11
12
13
require "twitter" # include lib/gem


# set the configuration object with the application and access tokens provided by registering an app on twitter site

config = {
  consumer_key: 'YOUR_consumerkey', 
  consumer_secret: 'YOUR_consumersecret', 
  access_token: 'YOUR_accesstoken', 
  access_token_secret: 'YOUR_accesstokensecret'
}
client = Twitter::REST::Client.new(config) # instantiate the working object


client.update('Tweet from simple ruby client.') # execute a status update (a tweet)

# perform as many other operations you want with the client object, read the gem page (see "references") ...

References