Class: OauthChina::Douban
- Defined in:
- lib/oauth_china/strategies/douban.rb
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) ⇒ Douban
constructor
A new instance of Douban.
- #name ⇒ Object
-
#upload_image(content, image_path, options = {}) ⇒ Object
TODO.
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) ⇒ Douban
Returns a new instance of Douban.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/oauth_china/strategies/douban.rb', line 4 def initialize(*args) #豆瓣只支持header方式呀! self. = { :signature_method => "HMAC-SHA1", :site => "http://www.douban.com", :scheme => :header, :request_token_path => '/service/auth/request_token', :access_token_path => '/service/auth/access_token', :authorize_path => '/service/auth/authorize', :realm => url } super(*args) end |
Instance Method Details
#add_status(content, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/oauth_china/strategies/douban.rb', line 33 def add_status(content, = {}) self.post("http://api.douban.com/miniblog/saying", <<-XML, {"Content-Type" => "application/atom+xml"}) <?xml version='1.0' encoding='UTF-8'?> <entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/"> <content>#{content}</content> </entry> XML end |
#authorized? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/oauth_china/strategies/douban.rb', line 22 def return false if access_token.nil? response = self.get("/access_token/#{access_token.token}") response.code == '200' end |
#destroy ⇒ Object
28 29 30 31 |
# File 'lib/oauth_china/strategies/douban.rb', line 28 def destroy destroy_access_key if !access_token.nil? request_token = access_token = nil end |
#name ⇒ Object
18 19 20 |
# File 'lib/oauth_china/strategies/douban.rb', line 18 def name :douban end |
#upload_image(content, image_path, options = {}) ⇒ Object
TODO
43 44 45 |
# File 'lib/oauth_china/strategies/douban.rb', line 43 def upload_image(content, image_path, = {}) add_status(content, ) end |