Raise error when no access token/secret pair set
[twitter4r-core.git] / examples / auth.rb
blob9b87e41eab3a4a6ddb13bf3b13c32eeb064b93a0
1 require('twitter')
2 require('twitter/console')
4 ## NOTE: OAUTH authentication:
6 # For Twitter4R v 0.5.0 and above...
7 # Supply the OAuth access key and secret respective to the constructor
8 # to use the client in authenticated mode for subsequent calls.
9 client = Twitter::Client.new(access_key, access_secret)
10 # If you only want to use the Twitter4R client to ensure the keys are 
11 # still authorized you can validate the credentials your applicaiton 
12 # has for the user this way:
13 client = Twitter::Client.new
14 puts client.autenticate?(access_key, access_secret)
16 ## For Twitter4R v0.4.0 and below...
17 ## OLD: Below is a demonstration of the old username/password scheme.
18 ## Twitter.com completely removes support for this on August 31, 2010.
19 # Supply the username and password of the user to the constructor to 
20 # use the client in authenticated mode for subsequent calls.
21 client = Twitter::Client.new("osxisforlightweights","sn0wl30p@rd_s^cks!")
23 # If you only want to use the Twitter4R client to ensure the keys are
24 # still authorized you can validate the credentials your application 
25 # has for the user this way:
26 client = Twitter::Client.new
27 # This will only verify credentials NOT save the username and password 
28 # for use in subsequent calls.
29 puts client.authenticate?("osxisforlightweights", "l30p@rd_s^cks!")