oauth_china 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,49 +1,38 @@
1
1
  一.简介:
2
- OAuth gem for rails,支持豆瓣,新浪微薄,qq微薄
2
+
3
+ OAuth gem for rails,支持豆瓣,新浪微薄,qq微薄
3
4
 
4
5
  二.安装:
5
- $ gem install oauth_china
6
+
7
+ $ gem install oauth_china
6
8
 
7
9
  三.使用:
8
10
 
9
- 1. 在Gemfile里添加:
10
-
11
- gem 'oauth_china'
12
-
13
- 2. 添加配置文件
14
-
15
- config/oauth/douban.yml
16
- config/oauth/sina.yml
17
- config/oauth/qq.yml
18
-
19
- 例子:
20
-
21
- development:
22
- key: "you api key"
23
- secret: "your secret"
24
- url: "http://yoursite.com"
25
- callback: "http://localhost:3000/your_callback_url"
26
- production:
27
- key: "you api key"
28
- secret: "your secret"
29
- url: "http://yoursite.com"
30
- callback: "http://localhost:3000/your_callback_url"
31
-
32
- 3.Example
33
- if params[:oauth_token]
34
- sina = OauthChina::Sina.load(Rails.cache.read(params[:oauth_token]))
35
- sina.authorize(:oauth_verifier => params[:oauth_verifier])
36
- #resp0 = sina.get("http://api.douban.com/people/%40me")
37
- #resp1 = sina.get("http://open.t.qq.com/api/user/info?format=json")
38
- resp = sina.get("/account/verify_credentials.xml")
39
- render :text => resp.body
40
- else
41
- sina = OauthChina::Sina.new
42
- url = sina.authorize_url
43
- Rails.cache.write(sina.oauth_token, sina.dump)
44
- redirect_to url
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/
11
+ 1. 在Gemfile里添加:
12
+
13
+ gem 'oauth_china'
14
+
15
+ 2. 添加配置文件
16
+
17
+ config/oauth/douban.yml
18
+ config/oauth/sina.yml
19
+ config/oauth/qq.yml
20
+
21
+ 配置文件格式:
22
+ development:
23
+ key: "you api key"
24
+ secret: "your secret"
25
+ url: "http://yoursite.com"
26
+ callback: "http://localhost:3000/your_callback_url"
27
+ production:
28
+ key: "you api key"
29
+ secret: "your secret"
30
+ url: "http://yoursite.com"
31
+ callback: "http://localhost:3000/your_callback_url"
32
+
33
+ 3.演示[TODO]
34
+
35
+ 四.API文档
36
+ 腾讯微博API文档:http://open.t.qq.com/resource.php?i=1,1
37
+ 新浪微博API文档:http://open.t.sina.com.cn/wiki/index.php/API%E6%96%87%E6%A1%A3
38
+ 豆瓣微博API文档:http://www.douban.com/service/apidoc/reference/
@@ -1,3 +1,3 @@
1
1
  module OauthChina
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/oauth_china.rb CHANGED
@@ -29,11 +29,8 @@ module OauthChina
29
29
  end
30
30
 
31
31
  def self.load(data)
32
- access_token = data[:access_token]
33
- access_token_secret = data[:access_token_secret]
34
-
35
32
  oauth = self.new(data[:request_token], data[:request_token_secret])
36
- oauth.access_token = ::OAuth::AccessToken.new(consumer, access_token, access_token_secret) if access_token
33
+ oauth.access_token = ::OAuth::AccessToken.new(oauth.consumer, data[:access_token], data[:access_token_secret]) if data[:access_token] && data[:access_token_secret]
37
34
  oauth
38
35
  end
39
36
 
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: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hooopo