lib/milk_cap/rtm/base.rb in milk_cap-0.5.0 vs lib/milk_cap/rtm/base.rb in milk_cap-0.5.1

- old
+ new

@@ -18,13 +18,12 @@ # THE SOFTWARE. # # Made in Japan. #++ - -require 'rufus/verbs' - +require 'cgi' +require 'net/http' require 'json' # gem install 'json' or 'json_pure' begin require 'md5' @@ -44,11 +43,11 @@ module MilkCap module RTM - VERSION = '0.5.0' + VERSION = '0.5.1' AUTH_ENDPOINT = "http://www.rememberthemilk.com/services/auth/" REST_ENDPOINT = "http://api.rememberthemilk.com/services/rest/" # Signs the RTM request (sets the 'api_sig' parameter). @@ -87,19 +86,25 @@ secret = params[:shared_secret] || ENV['RTM_SHARED_SECRET'] sign(ps, secret) - res = Rufus::Verbs.get(endpoint, :query => ps) + res = get(endpoint, ps) - JSON.parse(res.body)['rsp'] + JSON.parse(res)['rsp'] end # Requests a timeline from RTM. # def self.get_timeline #:nodoc: milk(:method => 'rtm.timelines.create')['timeline'] + end + + def self.get(endpoint, hash) + query = hash.collect { |item| "#{item[0].to_s}=#{CGI.escape(item[1].to_s)}" }.join("&") + url = endpoint + '?' + query + Net::HTTP.get(URI.parse(url)) end end end