Class: OauthChina::Sina

Inherits:
OAuth
  • Object
show all
Defined in:
lib/oauth_china/strategies/sina.rb

Constant Summary

Constants inherited from OAuth

OAuth::CONFIG

Instance Attribute Summary

Attributes inherited from OAuth

#access_token, #consumer_options, #request_token

Instance Method Summary collapse

Methods inherited from OAuth

#authorize, #authorize_url, #callback, #config, #consumer, #dump, #key, load, #oauth_token, #secret, #url

Methods included from Upload

#params_without_pic_field, #set_multipart_field, #sign_without_pic_field, #upload

Constructor Details

#initialize(*args) ⇒ Sina

Returns a new instance of Sina.



4
5
6
7
8
9
10
11
12
13
# File 'lib/oauth_china/strategies/sina.rb', line 4

def initialize(*args)
  self.consumer_options = {
    :site               => 'http://api.t.sina.com.cn',
    :request_token_path => '/oauth/request_token',
    :access_token_path  => '/oauth/access_token',
    :authorize_path     => '/oauth/authorize',
    :realm              => url
  }
  super(*args)
end

Instance Method Details

#add_status(content, options = {}) ⇒ Object



27
28
29
30
# File 'lib/oauth_china/strategies/sina.rb', line 27

def add_status(content, options = {})
  options.merge!(:status => content)
  self.post("http://api.t.sina.com.cn/statuses/update.json", options)
end

#authorized?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/oauth_china/strategies/sina.rb', line 19

def authorized?
  #TODO
end

#destroyObject



23
24
25
# File 'lib/oauth_china/strategies/sina.rb', line 23

def destroy
  #TODO
end

#nameObject



15
16
17
# File 'lib/oauth_china/strategies/sina.rb', line 15

def name
  :sina
end

#upload_image(content, image_path, options = {}) ⇒ Object



33
34
35
36
# File 'lib/oauth_china/strategies/sina.rb', line 33

def upload_image(content, image_path, options = {})
  options = options.merge!(:status => content, :pic => File.open(image_path, "rb")).to_options
  upload("http://api.t.sina.com.cn/statuses/upload.json", options)
end