Class: OauthChina::Qq

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

Returns a new instance of Qq.



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

def initialize(*args)
  self.consumer_options = {
    :site => "https://open.t.qq.com",
    :request_token_path  => "/cgi-bin/request_token",
    :access_token_path   => "/cgi-bin/access_token",
    :authorize_path      => "/cgi-bin/authorize",
    :http_method         => :get,
    :scheme              => :query_string,
    :nonce               => nonce,
    :realm               => url
  }
  super(*args)
end

Instance Method Details

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



35
36
37
38
# File 'lib/oauth_china/strategies/qq.rb', line 35

def add_status(content, options = {})
  options.merge!(:content => content)
  self.post("http://open.t.qq.com/api/t/add", options)
end

#authorized?Boolean

Returns:

  • (Boolean)


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

def authorized?
  #TODO
end

#destroyObject



31
32
33
# File 'lib/oauth_china/strategies/qq.rb', line 31

def destroy
  #TODO
end

#nameObject



18
19
20
# File 'lib/oauth_china/strategies/qq.rb', line 18

def name
  :qq
end

#nonceObject

腾讯的nonce值必须32位随机字符串啊!



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

def nonce
  Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')[0, 32]
end

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

TODO 还未实现



42
43
44
# File 'lib/oauth_china/strategies/qq.rb', line 42

def upload_image(content, image_path, options = {})
  add_status(content, options)
end