Module: FlickRaw

Defined in:
lib/flickraw.rb

Defined Under Namespace

Modules: SimpleOStruct Classes: FailedResponse, Flickr, Request, Response

Constant Summary collapse

VERSION =
'0.5.1.2'
FLICKR_HOST =
'http://api.flickr.com'.freeze
REST_PATH =

Path of flickr REST API

'/services/rest/?'.freeze
AUTH_PATH =

Path of flickr auth page

'/services/auth/?'.freeze
UPLOAD_PATH =

Path of flickr upload

'/services/upload/'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Your flickr API key, see www.flickr.com/services/api/keys for more information



227
228
229
# File 'lib/flickraw.rb', line 227

def api_key
  @api_key
end

.shared_secretObject

The shared secret of api_key, see www.flickr.com/services/api/keys for more information



230
231
232
# File 'lib/flickraw.rb', line 230

def shared_secret
  @shared_secret
end

Class Method Details

.api_sig(hsh) ⇒ Object

Returns the signature of hsh. This is meant to be passed in the api_sig parameter.



242
243
244
# File 'lib/flickraw.rb', line 242

def api_sig(hsh)
  MD5.md5(FlickRaw.shared_secret + hsh.sort{|a, b| a[0].to_s <=> b[0].to_s }.flatten.join).to_s
end

.auth_url(args = {}) ⇒ Object

Returns the flickr auth URL.



233
234
235
236
237
238
239
# File 'lib/flickraw.rb', line 233

def auth_url(args={})
  full_args = {:api_key => FlickRaw.api_key, :perms => 'read'}
  args.each {|k, v| full_args[k.to_sym] = v }
  full_args[:api_sig] = api_sig(full_args) if FlickRaw.shared_secret

  FLICKR_HOST + AUTH_PATH + full_args.collect { |a, v| "#{a}=#{v}" }.join('&')
end