Class: Flickr::OAuthCient
- Inherits:
-
Object
- Object
- Flickr::OAuthCient
- Defined in:
- lib/flickrrb.rb
Class Method Summary collapse
-
.authorize ⇒ Object
def post path, params, headers = {} @access.post path, params, headers end.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(params = {}) ⇒ OAuthCient
constructor
A new instance of OAuthCient.
Constructor Details
#initialize(params = {}) ⇒ OAuthCient
Returns a new instance of OAuthCient.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/flickrrb.rb', line 285 def initialize params = {} flickr_url = URI.parse "http://api.flickr.com/" consumer = OAuth::Consumer.new(params[:consumer_key], params[:consumer_secret], site: "http://api.flickr.com/", request_token_path: "/services/oauth/request_token", access_token_path: "/services/oauth/access_token", authorize_path: "/services/oauth/authorize") access_keys = {oauth_token: params[:access_token], oauth_token_secret: params[:access_secret]} @access = OAuth::AccessToken.from_hash(consumer, access_keys) end |
Class Method Details
.authorize ⇒ Object
def post path, params, headers = {}
@access.post path, params, headers
end
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/flickrrb.rb', line 308 def self. print "Enter consumer key: " consumer_key = $stdin.gets.chomp print "Enter consumer secret: " consumer_secret = $stdin.gets.chomp consumer = OAuth::Consumer.new(consumer_key, consumer_secret, site: 'http://www.flickr.com', # Note www request_token_path: "/services/oauth/request_token", access_token_path: "/services/oauth/access_token", authorize_path: "/services/oauth/authorize") request_token = consumer.get_request_token p "\nGo to this url and click 'Authorize' to get the token:" p request_token. print "\nEnter token: " token = $stdin.gets.chomp access_token = request_token.get_access_token(:oauth_verifier => token) p "\nAuthorisation complete! Use the following params to access Flickr:\n\n" p "consumer_key = '#{consumer.key}'" p "consumer_secret = '#{consumer.secret}'" p "access_token = '#{access_token.token}'" p "access_secret = '#{access_token.secret}'" end |
Instance Method Details
#get(path) ⇒ Object
300 301 302 |
# File 'lib/flickrrb.rb', line 300 def get path @access.get path end |