Assembla home | Assembla project page
 

root/trunk/rails/lib/flickr_helper.rb

Revision 8, 0.5 kB (checked in by battlehorse, 10 months ago)

Fixes #7 . Google analytics support, app-wide configuration file

Line 
1 module FlickrAware
2   def self.api_key
3     AppConfig.flickr
4   end
5  
6   def self.invoke(method,params = {})
7     url = "http://api.flickr.com/services/rest/?method=#{method}&api_key=#{self.api_key}"
8     params.each_pair { |k,v| url += "&#{k.to_s}=#{URI.escape(v)}"} # k may be a symbol
9       
10     # puts url
11     r = Net::HTTP.get_response(URI.parse(url))
12     if r.kind_of? Net::HTTPSuccess
13       d = REXML::Document.new(r.body)   
14       return d if d.root.attributes["stat"] == "ok"
15     end
16     return nil
17   end
18 end
Note: See TracBrowser for help on using the browser.