Class: RBVIMEO::Vimeo
- Inherits:
-
Object
- Object
- RBVIMEO::Vimeo
- Defined in:
- lib/rbvimeo/vimeo.rb
Constant Summary collapse
- @@API_REST_URL =
"http://www.vimeo.com/api/rest/v2/"
- @@API_AUTH_URL =
"http://www.vimeo.com/services/auth/"
- @@API_UPLOAD_URL =
"http://www.vimeo.com/services/upload/"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
Instance Method Summary collapse
-
#generate_signature(parameters) ⇒ Object
parameters is a hash.
-
#generate_url(parameters, permissions = nil) ⇒ Object
@vimeo.generate_url(=> “vimeo.videos.getInfo”, “read”, “video_id” => “339189”, “api_key” => @vimeo.api_key) This example returns a url to the xml for the Vimeo video with id 339189.
-
#get_xml(url) ⇒ Object
Returns the xml from the given url.
-
#initialize(api_key, api_secret) ⇒ Vimeo
constructor
api_key and api_secret should both be generated on www.vimeo.com.
-
#user ⇒ Object
Provides easier access to RBVIMEO::User user = @vimeo.user.
-
#video(id) ⇒ Object
Provides easier access to RBVIMEO::Video video = @vimeo.video 339189.
Constructor Details
#initialize(api_key, api_secret) ⇒ Vimeo
api_key and api_secret should both be generated on www.vimeo.com
10 11 12 13 |
# File 'lib/rbvimeo/vimeo.rb', line 10 def initialize api_key, api_secret @api_key = api_key @api_secret = api_secret end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/rbvimeo/vimeo.rb', line 3 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
3 4 5 |
# File 'lib/rbvimeo/vimeo.rb', line 3 def api_secret @api_secret end |
Instance Method Details
#generate_signature(parameters) ⇒ Object
parameters is a hash
34 35 36 37 38 39 40 41 42 |
# File 'lib/rbvimeo/vimeo.rb', line 34 def generate_signature parameters temp = '' params = parameters.sort params.each do |array| temp += array[0].to_s + array[1].to_s end signature = @api_secret + temp Digest::MD5.hexdigest(signature) end |
#generate_url(parameters, permissions = nil) ⇒ Object
@vimeo.generate_url(=> “vimeo.videos.getInfo”, “read”,
"video_id" => "339189", "api_key" => @vimeo.api_key)
This example returns a url to the xml for the Vimeo video with id 339189
18 19 20 21 22 23 24 25 26 |
# File 'lib/rbvimeo/vimeo.rb', line 18 def generate_url parameters, = nil url = "#{@@API_REST_URL}?api_key=#{@api_key}" params = parameters.sort params.each do |param| url += "&#{param[0]}=#{param[1]}" unless param[0].to_s == "api_key" end url += "&api_sig=#{generate_signature(parameters)}" return url end |
#get_xml(url) ⇒ Object
Returns the xml from the given url
29 30 31 |
# File 'lib/rbvimeo/vimeo.rb', line 29 def get_xml url return Hpricot(open(url)) end |
#user ⇒ Object
Provides easier access to RBVIMEO::User user = @vimeo.user
54 55 56 |
# File 'lib/rbvimeo/vimeo.rb', line 54 def user return User.new end |