lib/http_services.rb in koala-0.5.0 vs lib/http_services.rb in koala-0.6.0
- old
+ new
@@ -4,18 +4,19 @@
def self.included(base)
base.class_eval do
require 'net/http' unless defined?(Net::HTTP)
require 'net/https'
- def self.make_request(path, args, verb)
+ def self.make_request(path, args, verb, options = {})
# We translate args to a valid query string. If post is specified,
# we send a POST request to the given path with the given arguments.
# if the verb isn't get or post, send it as a post argument
args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
- http = Net::HTTP.new(Facebook::GRAPH_SERVER, 443)
+ server = options[:rest_api] ? Facebook::REST_SERVER : Facebook::GRAPH_SERVER
+ http = Net::HTTP.new(server, 443)
http.use_ssl = true
# we turn off certificate validation to avoid the
# "warning: peer certificate won't be verified in this SSL session" warning
# not sure if this is the right way to handle it
# see http://redcorundum.blogspot.com/2008/03/ssl-certificates-and-nethttps.html
@@ -44,15 +45,16 @@
# this service uses Typhoeus to send requests to the graph
def self.included(base)
base.class_eval do
require 'typhoeus' unless defined?(Typhoeus)
include Typhoeus
-
- def self.make_request(path, args, verb)
+
+ def self.make_request(path, args, verb, options = {})
# if the verb isn't get or post, send it as a post argument
args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
- self.send(verb, "https://#{Facebook::GRAPH_SERVER}/#{path}", :params => args).body
+ server = options[:rest_api] ? Facebook::REST_SERVER : Facebook::GRAPH_SERVER
+ self.send(verb, "https://#{server}/#{path}", :params => args).body
end
- end
+ end # class_eval
end
end
end
\ No newline at end of file