oauth_china 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -42,4 +42,8 @@ production:
42
42
  url = sina.authorize_url
43
43
  Rails.cache.write(sina.oauth_token, sina.dump)
44
44
  redirect_to url
45
- end
45
+ end
46
+
47
+ 腾讯微博API文档:http://open.t.qq.com/resource.php?i=1,1
48
+ 新浪微博API文档:http://open.t.sina.com.cn/wiki/index.php/API%E6%96%87%E6%A1%A3
49
+ 豆瓣微博API文档:http://www.douban.com/service/apidoc/reference/
@@ -19,11 +19,29 @@ module OauthChina
19
19
  end
20
20
 
21
21
  def authorized?
22
- #TODO
22
+ return false if access_token.nil?
23
+ response = self.get("/access_token/#{access_token.token}")
24
+ response.code == '200'
23
25
  end
24
26
 
25
27
  def destroy
26
- #TODO
28
+ destroy_access_key if !access_token.nil?
29
+ request_token = access_token = nil
30
+ end
31
+
32
+ def add_status(content, options = {})
33
+ self.post("http://api.douban.com/miniblog/saying", <<-XML, {"Content-Type" => "application/atom+xml"})
34
+ <?xml version='1.0' encoding='UTF-8'?>
35
+ <entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/">
36
+ <content>#{content}</content>
37
+ </entry>
38
+ XML
39
+ end
40
+
41
+ protected
42
+ def destroy_access_key
43
+ response = delete("/access_token/#{access_token.token}")
44
+ response.code == '200'
27
45
  end
28
46
  end
29
47
  end
@@ -30,5 +30,10 @@ module OauthChina
30
30
  def destroy
31
31
  #TODO
32
32
  end
33
+
34
+ def add_status(content, options = {})
35
+ options.merge!(:content => content)
36
+ self.post("http://open.t.qq.com/api/t/add", options)
37
+ end
33
38
  end
34
39
  end
@@ -23,5 +23,10 @@ module OauthChina
23
23
  def destroy
24
24
  #TODO
25
25
  end
26
+
27
+ def add_status(content, options = {})
28
+ options.merge!(:status => content)
29
+ self.post("http://api.t.sina.com.cn/statuses/update.json", options)
30
+ end
26
31
  end
27
32
  end
@@ -1,3 +1,3 @@
1
1
  module OauthChina
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/oauth_china.rb CHANGED
@@ -19,7 +19,7 @@ module OauthChina
19
19
  end
20
20
  end
21
21
 
22
- #每次认证等唯一标志
22
+ #每次认证的唯一标志
23
23
  def oauth_token
24
24
  request_token.params[:oauth_token]
25
25
  end
@@ -29,11 +29,11 @@ module OauthChina
29
29
  end
30
30
 
31
31
  def self.load(data)
32
- a_token = data[:access_token]
33
- a_token_secret = data[:access_token_secret]
32
+ access_token = data[:access_token]
33
+ access_token_secret = data[:access_token_secret]
34
34
 
35
35
  oauth = self.new(data[:request_token], data[:request_token_secret])
36
- oauth.access_token = ::OAuth::AccessToken.new(consumer, a_token, a_token_secret) if a_token
36
+ oauth.access_token = ::OAuth::AccessToken.new(consumer, access_token, access_token_secret) if access_token
37
37
  oauth
38
38
  end
39
39
 
@@ -68,8 +68,8 @@ module OauthChina
68
68
  #QQ和新浪OAuth需要verifier参数,豆瓣不需要
69
69
  def authorize(options = {})
70
70
  return unless self.access_token.nil?
71
- a_token = self.request_token.get_access_token(options)
72
- self.access_token ||= ::OAuth::AccessToken.new(consumer, a_token.token, a_token.secret)
71
+ token = self.request_token.get_access_token(options)
72
+ self.access_token ||= ::OAuth::AccessToken.new(consumer, token.token, token.secret)
73
73
  end
74
74
 
75
75
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth_china
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
4
+ hash: 25
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hooopo
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-20 00:00:00 +08:00
18
+ date: 2011-03-24 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements: []
86
86
 
87
87
  rubyforge_project: oauth_china
88
- rubygems_version: 1.6.2
88
+ rubygems_version: 1.3.7
89
89
  signing_key:
90
90
  specification_version: 3
91
91
  summary: !binary |