douban_api 0.1.3 → 0.1.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.md +7 -0
- data/lib/douban_api/client/event.rb +4 -4
- data/lib/douban_api/oauth.rb +13 -5
- data/lib/douban_api/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
# douban_api
|
2
|
+
|
2
3
|
Simple Ruby wrapper for [Douban API V2](http://developers.douban.com/wiki/?title=api_v2)
|
4
|
+
|
3
5
|
这个项目仍在开发中,缺少文档和测试,欢迎贡献。
|
4
6
|
## Installation
|
5
7
|
gem install douban_api
|
6
8
|
|
7
9
|
|
8
10
|
## Sample Sinatra App
|
11
|
+
|
12
|
+
完整的应用请到 https://github.com/seansay/douban_api_sinatra_example
|
13
|
+
|
14
|
+
Demo: http://doubanapi.notimportant.org/
|
15
|
+
|
9
16
|
require 'rubygems'
|
10
17
|
require 'sinatra'
|
11
18
|
require 'haml'
|
@@ -26,8 +26,8 @@ module Douban
|
|
26
26
|
# @return [Array<Hashie::Mash>] 用户列表
|
27
27
|
# @example 获取参与 id为17790089 活动的用户
|
28
28
|
# Douban.event_participants('17790089')
|
29
|
-
def event_participants(id)
|
30
|
-
response = get
|
29
|
+
def event_participants(id, options={})
|
30
|
+
response = get("v2/event/#{id}/participants", options)
|
31
31
|
response["users"]
|
32
32
|
end
|
33
33
|
|
@@ -40,8 +40,8 @@ module Douban
|
|
40
40
|
# @return [Array<Hashie::Mash>] 用户列表
|
41
41
|
# @example 获取对 id为17790089 活动感兴趣的用户
|
42
42
|
# Douban.event_wishers('17790089')
|
43
|
-
def event_wishers(id)
|
44
|
-
response = get
|
43
|
+
def event_wishers(id, options={})
|
44
|
+
response = get("v2/event/#{id}/wishers", options)
|
45
45
|
response["users"]
|
46
46
|
end
|
47
47
|
|
data/lib/douban_api/oauth.rb
CHANGED
@@ -13,15 +13,23 @@ module Douban
|
|
13
13
|
def get_access_token(code, options={})
|
14
14
|
options[:grant_type] ||= "authorization_code"
|
15
15
|
params = access_token_params.merge(options)
|
16
|
-
post("https://www.douban.com/service/auth2/token",
|
16
|
+
response = post("https://www.douban.com/service/auth2/token",
|
17
|
+
params.merge(:code => code),
|
18
|
+
raw=false)
|
17
19
|
end
|
18
|
-
|
20
|
+
|
21
|
+
# Refresh you access token, see OAuth2 spec for more infomation
|
22
|
+
# @see http://developers.douban.com/wiki/?title=oauth2
|
23
|
+
# @note 返回新的access_token和refresh_token的同时, 它修改client的access_token和refresh_token
|
19
24
|
def refresh(options={})
|
20
25
|
options[:grant_type] ||= "refresh_token"
|
21
26
|
params = access_token_params.merge(options)
|
22
|
-
post("https://www.douban.com/service/auth2/token",
|
23
|
-
|
24
|
-
|
27
|
+
response = post("https://www.douban.com/service/auth2/token",
|
28
|
+
params.merge(:refresh_token => refresh_token),
|
29
|
+
raw=false)
|
30
|
+
@access_token, @refresh_token = response[:access_token], response[:refresh_token]
|
31
|
+
|
32
|
+
response
|
25
33
|
end
|
26
34
|
|
27
35
|
private
|
data/lib/douban_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: douban_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -253,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
253
|
version: '0'
|
254
254
|
segments:
|
255
255
|
- 0
|
256
|
-
hash:
|
256
|
+
hash: 410308200798971739
|
257
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
258
|
none: false
|
259
259
|
requirements:
|