Class: Facebooker::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/facebooker/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_base, api_path, api_key) ⇒ Service

Returns a new instance of Service.



5
6
7
8
9
# File 'lib/facebooker/service.rb', line 5

def initialize(api_base, api_path, api_key)
  @api_base = api_base
  @api_path = api_path
  @api_key = api_key
end

Instance Method Details

#post(params) ⇒ Object

TODO: support ssl



12
13
14
15
16
17
18
19
20
# File 'lib/facebooker/service.rb', line 12

def post(params)
  attempt = 0
  Parser.parse(params[:method], Net::HTTP.post_form(url, params))
rescue Errno::ECONNRESET, EOFError
  if attempt == 0
    attempt += 1
    retry
  end
end

#post_file(params) ⇒ Object



22
23
24
# File 'lib/facebooker/service.rb', line 22

def post_file(params)
  Parser.parse(params[:method], Net::HTTP.post_multipart_form(url, params))
end