lib/bobot/graph_facebook.rb in bobot-3.0.5 vs lib/bobot/graph_facebook.rb in bobot-3.0.6
- old
+ new
@@ -1,22 +1,23 @@
-require "Typhoeus"
+require "typhoeus"
require "uri"
module Bobot
module GraphFacebook
- GRAPH_FB_URL = 'https://graph.facebook.com/v2.11/'.freeze
+ GRAPH_FB_URL = 'https://graph.facebook.com/v2.11'.freeze
GRAPH_HEADERS = { Accept: "application/json", "Content-Type" => "application/json; charset=utf-8" }.freeze
module ClassMethods
def graph_get(path, query: {})
url = "#{GRAPH_FB_URL}#{path}".freeze
- req = Typhoeus::Request.new(
+ req = ::Typhoeus::Request.new(
url,
method: :get,
params: URI.encode_www_form(query.reverse_merge(include_headers: false)),
headers: GRAPH_HEADERS,
ssl_verifypeer: false,
+ verbose: false,
).run
response = req.run
json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
Rails.logger.debug "[GET] >> #{url}"
Rails.logger.debug "[GET] << #{json}"
@@ -25,17 +26,18 @@
end
module_function :graph_get
def graph_post(path, query: {}, body: {})
url = "#{GRAPH_FB_URL}#{path}".freeze
- req = Typhoeus::Request.new(
+ req = ::Typhoeus::Request.new(
url,
method: :post,
params: URI.encode_www_form(query.reverse_merge(include_headers: false)),
body: ActiveSupport::JSON.encode(body),
headers: GRAPH_HEADERS,
ssl_verifypeer: false,
+ verbose: false,
)
response = req.run
json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
Rails.logger.debug "[POST] >> #{url}"
Rails.logger.debug "[POST] << #{json}"
@@ -44,16 +46,17 @@
end
module_function :graph_post
def graph_delete(path, query: {}, body: {})
url = "#{GRAPH_FB_URL}#{path}".freeze
- req = Typhoeus::Request.new(
+ req = ::Typhoeus::Request.new(
url,
method: :delete,
params: URI.encode_www_form(query.reverse_merge(include_headers: false)),
body: ActiveSupport::JSON.encode(body),
headers: GRAPH_HEADERS,
ssl_verifypeer: false,
+ verbose: false,
)
response = req.run
json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
Rails.logger.debug "[DELETE] >> #{url}"
Rails.logger.debug "[DELETE] << #{json}"