Class: Renren::Base
- Inherits:
-
Object
- Object
- Renren::Base
- Defined in:
- lib/renren/base.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #call_method(opts = {:method => "users.getInfo"}) ⇒ Object
-
#initialize(access_token) ⇒ Base
constructor
A new instance of Base.
- #upload_file(filename, opts = {}) ⇒ Object
Constructor Details
#initialize(access_token) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 18 19 |
# File 'lib/renren/base.rb', line 12 def initialize(access_token) @params = {} @params[:method] = "friends.get" @params[:call_id] = Time.now.to_i @params[:format] = 'json' @params[:v] = '1.0' @params[:access_token] = access_token end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
10 11 12 |
# File 'lib/renren/base.rb', line 10 def params @params end |
Instance Method Details
#call_method(opts = {:method => "users.getInfo"}) ⇒ Object
21 22 23 |
# File 'lib/renren/base.rb', line 21 def call_method(opts = {:method => "users.getInfo"}) MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), update_params(opts)).body) end |
#upload_file(filename, opts = {}) ⇒ Object
25 26 27 |
# File 'lib/renren/base.rb', line 25 def upload_file(filename, opts = {}) MultiJson.decode(RestClient.post('http://api.renren.com/restserver.do', update_params(opts).merge(:upload => File.new(filename)))) end |