Class: OauthChina::Qq
Constant Summary
Constants inherited from OAuth
Instance Attribute Summary
Attributes inherited from OAuth
#access_token, #consumer_options, #request_token
Instance Method Summary collapse
- #add_status(content, options = {}) ⇒ Object
- #authorized? ⇒ Boolean
- #destroy ⇒ Object
-
#initialize(*args) ⇒ Qq
constructor
A new instance of Qq.
- #name ⇒ Object
-
#nonce ⇒ Object
腾讯的nonce值必须32位随机字符串啊!.
- #upload_image(content, image_path, options = {}) ⇒ Object
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. = { :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, = {}) .merge!(:content => content) self.post("http://open.t.qq.com/api/t/add", ) end |
#authorized? ⇒ Boolean
27 28 29 |
# File 'lib/oauth_china/strategies/qq.rb', line 27 def #TODO end |
#destroy ⇒ Object
31 32 33 |
# File 'lib/oauth_china/strategies/qq.rb', line 31 def destroy #TODO end |
#name ⇒ Object
18 19 20 |
# File 'lib/oauth_china/strategies/qq.rb', line 18 def name :qq end |
#nonce ⇒ Object
腾讯的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
41 42 43 44 45 46 |
# File 'lib/oauth_china/strategies/qq.rb', line 41 def upload_image(content, image_path, = {}) = .merge!(:content => content, :pic => File.open(image_path, "rb")). self.consumer.[:site] = "http://open.t.qq.com/api/t/add_pic" self.consumer.uri("http://open.t.qq.com/api/t/add_pic") upload("http://open.t.qq.com/api/t/add_pic", ) end |