Class: RenrenMobile::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/renren-mobile/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
18
# File 'lib/renren-mobile/base.rb', line 12

def initialize(access_token)
  @params = {}
  @params[:call_id] = Time.now.to_i
  @params[:format] = 'json'
  @params[:v] = '1.0'
  @params[:access_token] = access_token
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



10
11
12
# File 'lib/renren-mobile/base.rb', line 10

def params
  @params
end

Instance Method Details

#call_method(method, opts = {}) ⇒ Object



20
21
22
23
# File 'lib/renren-mobile/base.rb', line 20

def call_method(method, opts = {})
  method = method.gsub(".", "/")
  MultiJson.decode(Net::HTTP.post_form(URI.parse("http://api.m.renren.com/api/#{method}"), update_params(opts)).body)
end

#upload_file(method, filename, opts = {}) ⇒ Object



25
26
27
28
# File 'lib/renren-mobile/base.rb', line 25

def upload_file(method, filename, opts = {})
  method = method.gsub(".", "/")
  MultiJson.decode(RestClient.post('http://api.m.renren.com/api/#{method}', update_params(opts).merge(:data => File.new(filename))))
end