Class: OauthChina::Sohu

Inherits:
OAuth
  • Object
show all
Defined in:
lib/oauth_china/strategies/sohu.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) ⇒ Sohu

Returns a new instance of Sohu.



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

def initialize(*args)
  #搜狐微博的OAUTH 只支持将OAuth的认证参数放在HTTP的头部中。而且不可以带realm参数
  self.consumer_options = {
    :site               => 'http://api.t.sohu.com',
    :scheme             => :header,
    :request_token_path => '/oauth/request_token',
    :access_token_path  => '/oauth/access_token',
    :authorize_path     => '/oauth/authorize'
  }
  super(*args)
end

Instance Method Details

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



28
29
30
31
# File 'lib/oauth_china/strategies/sohu.rb', line 28

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

#authorized?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/oauth_china/strategies/sohu.rb', line 20

def authorized?
  #TODO
end

#destroyObject



24
25
26
# File 'lib/oauth_china/strategies/sohu.rb', line 24

def destroy
  #TODO
end

#nameObject



16
17
18
# File 'lib/oauth_china/strategies/sohu.rb', line 16

def name
  :sohu
end

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



33
34
35
36
# File 'lib/oauth_china/strategies/sohu.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.sohu.com/statuses/upload.json", options)
end