douban_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ module Douban
2
+ class Client
3
+ # 论坛API V2 http://developers.douban.com/wiki/?title=discussion_v2
4
+ module Discussion
5
+ def discussion(id)
6
+ get "v2/discussion/#{id}"
7
+ end
8
+
9
+ def update_discussion(id, options={})
10
+ put "v2/discussion/#{id}", options
11
+ end
12
+
13
+ def delete_discussion(id)
14
+ delete "v2/discussion/#{id}"
15
+ end
16
+
17
+ def create_discussion(id ,options={})
18
+ post "v2/target/#{id}/discussions", options
19
+ end
20
+
21
+ def discussions(id, options={})
22
+ response = get("v2/target/#{id}/discussions", options)
23
+ response["discussions"]
24
+ end
25
+
26
+ def discussion_comments(id, options={})
27
+ comments('discussion', id, options={})
28
+ end
29
+
30
+ def create_discussion_comment(id, content)
31
+ create_comment('discussion', id, content)
32
+ end
33
+
34
+ def discussion_comment(discussion_id, comment_id)
35
+ comment('discussion', discussion_id, comment_id)
36
+ end
37
+
38
+ def remove_discussion_comment(discussion_id, comment_id)
39
+ remove_comment('discussion', discussion_id, comment_id)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,120 @@
1
+ module Douban
2
+ class Client
3
+ # 豆邮Api V2 http://developers.douban.com/wiki/?title=doumail_v2
4
+ module Doumail
5
+ # 获取一封邮件
6
+ #
7
+ # @see http://developers.douban.com/wiki/?title=doumail_v2#get_mail
8
+ # @scope community_advanced_doumail_r
9
+ # @authenticated true
10
+ # @param id [String] 豆邮的id
11
+ # @return [Hashie::Mash] 豆邮信息
12
+ # @example 获取 id为281922967 的豆邮
13
+ # client.doumail('281922967')
14
+ def doumail(id, keep_unread=false)
15
+ response = get("v2/doumail/#{id}", :"keep-unread" => keep_unread)
16
+ end
17
+
18
+ # 获取用户收件箱
19
+ #
20
+ # @see http://developers.douban.com/wiki/?title=doumail_v2#inbox
21
+ # @scope community_advanced_doumail_r
22
+ # @authenticated true
23
+ # @return [Array<Hashie::Mash>] 豆邮列表
24
+ # @example 获取当前用户的收件箱
25
+ # client.inbox
26
+ def inbox(options={})
27
+ response = get "v2/doumail/inbox"
28
+ response["mails"]
29
+ end
30
+
31
+ # 获取用户发件箱
32
+ #
33
+ # @see http://developers.douban.com/wiki/?title=doumail_v2#outbox
34
+ # @scope community_advanced_doumail_r
35
+ # @authenticated true
36
+ # @return [Array<Hashie::Mash>] 豆邮列表
37
+ # @example 获取当前用户的发件箱
38
+ # client.outbox
39
+ def outbox(options={})
40
+ response = get "v2/doumail/outbox"
41
+ response["mails"]
42
+ end
43
+
44
+ # 获取用户未读邮件
45
+ #
46
+ # @see http://developers.douban.com/wiki/?title=doumail_v2#unread
47
+ # @scope community_advanced_doumail_r
48
+ # @authenticated true
49
+ # @return [Array<Hashie::Mash>] 豆邮列表
50
+ # @example 获取当前用户未读邮件
51
+ # client.unread
52
+ def unread(options={})
53
+ response = get "v2/doumail/inbox/unread"
54
+ response["mails"]
55
+ end
56
+
57
+ # 标记已读邮件
58
+ #
59
+ # @see http://developers.douban.com/wiki/?title=doumail_v2#read
60
+ # @scope community_advanced_doumail_w
61
+ # @authenticated true
62
+ # @param id [String] 豆邮的id
63
+ # @param id [Array<String>] 豆邮id的列表
64
+ # @return [Hashie::Mash] 豆邮信息
65
+ # @example 标记id为281740901的
66
+ # client.read("281740901")
67
+ # @example 标记多个豆邮为已读
68
+ # client.read(["281740901", "281745597"])
69
+ def read(id)
70
+ if id.is_a?(Array)
71
+ response = put("v2/doumail/read", :ids => id.join(','))
72
+ response["doumails"]
73
+ else
74
+ put "v2/doumail/#{id}"
75
+ end
76
+ end
77
+
78
+ # 删除豆邮
79
+ #
80
+ # @see http://developers.douban.com/wiki/?title=doumail_v2#delete
81
+ # @scope community_advanced_doumail_w
82
+ # @authenticated true
83
+ # @param id [String] 豆邮的id
84
+ # @param id [Array<String>] 豆邮id的列表
85
+ # @return [Hashie::Mash] 豆邮信息
86
+ # @example 删除id为281740901的删除
87
+ # client.delete_doumail("281740901")
88
+ # @example 删除多个豆邮
89
+ # client.delete_doumail(["281740901", "281745597"])
90
+ def delete_doumail(id)
91
+ if id.kind_of?(Array)
92
+ post "v2/doumail/delete", :ids => id.join(',')
93
+ else
94
+ post "v2/doumail/#{id}"
95
+ end
96
+ end
97
+
98
+ # 发送一封豆邮
99
+ #
100
+ # @see http://developers.douban.com/wiki/?title=doumail_v2#send
101
+ # @scope community_advanced_doumail_w
102
+ # @authenticated true
103
+ # @param receiver_id [String] 收件人的id
104
+ # @option options [String] :title 豆邮标题: 必填字段
105
+ # @option options [String] :content 豆邮正文: 必填字段
106
+ # @option options [String] :captcha_token 系统验证码 token: 选填字段
107
+ # @option options [String] :captcha_string 用户输入验证码: 选填字段
108
+ # @return [Hashie::Mash] 豆邮信息
109
+ # @example 发送一封豆邮
110
+ # client.send_doumail('48576635', {
111
+ # :title => "test",
112
+ # :content => "只是test"
113
+ # })
114
+ def send_doumail(receiver_id, options={})
115
+ options["receiver_id"] = receiver_id
116
+ post("v2/doumails", options) == {}
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,209 @@
1
+ module Douban
2
+ class Client
3
+ # 豆瓣同城 V2 http://developers.douban.com/wiki/?title=event_v2
4
+ module Event
5
+
6
+ # 获取活动
7
+ #
8
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_get
9
+ # @scope event_basic_r
10
+ # @authenticated false
11
+ # @param id [String] 活动的id
12
+ # @return [Hashie::Mash] 活动信息
13
+ # @example 获取 id为17790089 的活动信息
14
+ # Douban.event('17790089')
15
+ def event(id)
16
+ response = get "v2/event/#{id}"
17
+ end
18
+
19
+ # 获取参加活动的用户
20
+ #
21
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_participants
22
+ # @scope event_basic_r
23
+ # @authenticated false
24
+ # @param id [String] 活动的id
25
+ # @return [Array<Hashie::Mash>] 用户列表
26
+ # @example 获取参与 id为17790089 活动的用户
27
+ # Douban.event_participants('17790089')
28
+ def event_participants(id)
29
+ response = get "v2/event/#{id}/participants"
30
+ response["users"]
31
+ end
32
+
33
+ # 获取活动感兴趣的用户
34
+ #
35
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_wishers
36
+ # @scope event_basic_r
37
+ # @authenticated false
38
+ # @param id [String] 活动的id
39
+ # @return [Array<Hashie::Mash>] 用户列表
40
+ # @example 获取对 id为17790089 活动感兴趣的用户
41
+ # Douban.event_wishers('17790089')
42
+ def event_wishers(id)
43
+ response = get "v2/event/#{id}/wishers"
44
+ response["users"]
45
+ end
46
+
47
+ # 获取用户创建的活动
48
+ #
49
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_user_created
50
+ # @scope event_basic_r
51
+ # @authenticated false
52
+ # @param user_id [String] 用户的数字id
53
+ # @return [Array<Hashie::Mash>] 活动列表
54
+ # @example 获取 id为2217855 的用户创建的活动
55
+ # Douban.created_events('2217855')
56
+ # @example 获取已认证的用户创建的活动
57
+ # client.created_events()
58
+ def created_events(user_id=nil, options={})
59
+ if user_id.nil?
60
+ response = get("v2/event/user_created/#{get_user_id}", options)
61
+ else
62
+ response = get("v2/event/user_created/#{user_id}", options)
63
+ end
64
+
65
+ response["events"]
66
+ end
67
+
68
+ # 获取用户参加的活动
69
+ #
70
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_user_participated
71
+ # @scope event_basic_r
72
+ # @authenticated false
73
+ # @param user_id [String] 用户的数字id
74
+ # @return [Array<Hashie::Mash>] 活动列表
75
+ # @example 获取 id为2217855 的用户参加的活动
76
+ # Douban.participated_events('2217855')
77
+ # @example 获取已认证的用户参加的活动
78
+ # client.participated_events()
79
+ def participated_events(user_id=nil)
80
+ if user_id.nil?
81
+ response = get "v2/event/user_participated/#{get_user_id}"
82
+ else
83
+ response = get "v2/event/user_participated/#{user_id}"
84
+ end
85
+
86
+ response["events"]
87
+ end
88
+
89
+ # 获取用户参加的活动
90
+ #
91
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_user_wished
92
+ # @scope event_basic_r
93
+ # @authenticated false
94
+ # @param user_id [String] 用户的数字id
95
+ # @return [Array<Hashie::Mash>] 活动列表
96
+ # @example 获取 id为2217855 的用户感兴趣的活动
97
+ # Douban.wished_events('2217855')
98
+ # @example 获取已认证的用户感兴趣的活动
99
+ # client.wished_events()
100
+ def wished_events(user_id=nil)
101
+ if user_id.nil?
102
+ response = get "v2/event/user_wished/#{get_user_id}"
103
+ else
104
+ response = get "v2/event/user_wished/#{user_id}"
105
+ end
106
+
107
+ response["events"]
108
+ end
109
+
110
+ # 获取活动列表
111
+ #
112
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_list
113
+ # @scope event_basic_r
114
+ # @authenticated false
115
+ # @param loc_id [String] 城市id
116
+ # @option options [String] :day_type
117
+ # 时间类型: future, week, weekend, today, tomorrow
118
+ # @option options [String] :type
119
+ # 活动类型: all,music, film, drama, commonweal, salon, exhibition, party, sports, travel, others
120
+ # @return [Array<Hashie::Mash>] 活动列表
121
+ # @example 查看北京地区的音乐活动
122
+ # Douban.events('108288', :type => "music")
123
+ def events(loc_id, options={})
124
+ response = get("v2/event/list", options.merge(:loc => loc_id))
125
+ response["events"]
126
+ end
127
+
128
+ # 获取城市
129
+ #
130
+ # @see http://developers.douban.com/wiki/?title=event_v2#loc_get
131
+ # @scope event_basic_r
132
+ # @authenticated false
133
+ # @param loc_id [String] 城市id
134
+ # @return [Hashie::Mash] 活动列表
135
+ # @example 查看北京的信息
136
+ # Douban.loc('108288')
137
+ def loc(id)
138
+ response = get "v2/loc/#{id}"
139
+ end
140
+
141
+ # 获取城市列表
142
+ #
143
+ # @see http://developers.douban.com/wiki/?title=event_v2#loc_list
144
+ # @scope event_basic_r
145
+ # @authenticated false
146
+ # @return [Array<Hashie::Mash>] 城市列表
147
+ # @example 城市列表
148
+ # Douban.loc_list
149
+ def loc_list(options={})
150
+ response = get("v2/loc/list", options)
151
+ response["locs"]
152
+ end
153
+
154
+ # 参加活动
155
+ #
156
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_participate
157
+ # @scope event_basic_w
158
+ # @authenticated true
159
+ # @param id [String] 活动的id
160
+ # @option options [String] :participate_date
161
+ # 参加时间: 时间格式:“%Y-%m-%d”,无此参数则时间待定
162
+ # @return [Hashie::Mash] 活动信息
163
+ # @example 参加 id为17717231 的活动
164
+ # client.participants_event('17717231')
165
+ def participants_event(id, options={})
166
+ post "v2/event/#{id}/participants", options
167
+ end
168
+
169
+ # 不参加活动
170
+ #
171
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_quit
172
+ # @scope event_basic_w
173
+ # @authenticated true
174
+ # @param id [String] 活动的id
175
+ # @return [Hashie::Mash] 活动信息
176
+ # @example 取消参加 id为17717231 的活动
177
+ # client.unparticipants_event('17717231')
178
+ def unparticipants_event(id)
179
+ delete "v2/event/#{id}/participants"
180
+ end
181
+
182
+ # 对活动感兴趣
183
+ #
184
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_wish
185
+ # @scope event_basic_w
186
+ # @authenticated true
187
+ # @param id [String] 活动的id
188
+ # @return [Hashie::Mash] 活动信息
189
+ # @example 对 id为17717231 的活动感兴趣
190
+ # client.wish_event('17717231')
191
+ def wish_event(id)
192
+ post "v2/event/#{id}/wishers"
193
+ end
194
+
195
+ # 对活动不感兴趣
196
+ #
197
+ # @see http://developers.douban.com/wiki/?title=event_v2#event_unwish
198
+ # @scope event_basic_w
199
+ # @authenticated true
200
+ # @param id [String] 活动的id
201
+ # @return [Hashie::Mash] 活动信息
202
+ # @example 对 id为17717231 的活动不感兴趣
203
+ # client.wish_event('17717231')
204
+ def unwish_event(id)
205
+ delete "v2/event/#{id}/wishers"
206
+ end
207
+ end
208
+ end
209
+ end
@@ -0,0 +1,157 @@
1
+ module Douban
2
+ class Client
3
+ # 电影Api V2 http://developers.douban.com/wiki/?title=movie_v2
4
+ module Movie
5
+ # 获取电影信息
6
+ #
7
+ # @see http://developers.douban.com/wiki/?title=movie_v2#get_movie
8
+ # @scope movie_basic_r
9
+ # @authenticated false
10
+ # @param id [String] 电影的id
11
+ # @return [Hashie::Mash] 电影信息
12
+ # @example 获取 id为1296987 的电影信息
13
+ # Douban.movie('1296987')
14
+ def movie(id)
15
+ response = get "v2/movie/#{id}"
16
+ end
17
+
18
+ # 根据imdb号获取电影信息
19
+ #
20
+ # @scope movie_basic_r
21
+ # @see http://developers.douban.com/wiki/?title=movie_v2#get_imdb_movie
22
+ # @authenticated false
23
+ # @param id [String] IMDb编号
24
+ # @return [Hashie::Mash] 电影信息
25
+ # @example 获取 IMDb编号为tt0075686 的图书信息
26
+ # Douban.imdb('tt0075686')
27
+ def imdb(id)
28
+ response = get "v2/movie/imdb/#{id}"
29
+ end
30
+
31
+ # 某个电影中标记最多的标签
32
+ #
33
+ # @scope movie_basic_r
34
+ # @see http://developers.douban.com/wiki/?title=movie_v2#get_movie_tags
35
+ # @authenticated false
36
+ # @param id [String] 电影的id
37
+ # @return [Array<Hashie::Mash>] 标签列表
38
+ # @example 获取 电影id为1296987 的标签
39
+ # Douban.movie_tags('1296987')
40
+ def movie_tags(id, optins={})
41
+ response = get "v2/movie/#{id}/tags", options
42
+ responses["tags"]
43
+ end
44
+
45
+ # 搜索电影
46
+ #
47
+ # @scope movie_basic_r
48
+ # @see http://developers.douban.com/wiki/?title=movie_v2#get_movie_search
49
+ # @authenticated false
50
+ # @param q [String] 查询关键字
51
+ # @return [Hashie::Mash] 电影列表
52
+ # @example 搜索电影 伍迪·艾伦 相关的电影
53
+ # Douban.search_movies("伍迪·艾伦")
54
+ def search_movies(q, options={})
55
+ response = get "v2/movie/search", options.merge(:q => q)
56
+ response["movies"]
57
+ end
58
+
59
+ # 搜索电影(通过标签)
60
+ #
61
+ # @scope movie_basic_r
62
+ # @see http://developers.douban.com/wiki/?title=movie_v2#get_movie_search
63
+ # @authenticated false
64
+ # @param tag [String] 查询的tag
65
+ # @return [Hashie::Mash] 电影列表
66
+ # @example 搜索含有标签 悬疑 的电影
67
+ # Douban.search_movies_by_tag("悬疑")
68
+ def search_movies_by_tag(tag, options={})
69
+ response = get "v2/movie/search", options.merge(:tag => tag)
70
+ response["movies"]
71
+ end
72
+
73
+ # 发表新评论
74
+ #
75
+ # @scope douban_basic_common
76
+ # @see http://developers.douban.com/wiki/?title=movie_v2#post_movie_review
77
+ # @authenticated true
78
+ # @param id [String] 电影的id
79
+ # @option options [String] :title 必传
80
+ # @option options [String] :content 必传,且多于150字
81
+ # @option options [Integer] :rating 非必传,数字1~5为合法值,其他信息默认为不打分
82
+ # @return [Hashie::Mash] 电影评论信息
83
+ # @example 给 id为1296987 的电影添加评论
84
+ # client.create_movie_review("1296987", {
85
+ # :title => "我们都需要鸡蛋",
86
+ # :content => "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
87
+ # 哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
88
+ # 哈哈哈哈哈哈哈哈哈哈哈哈...(省略一些哈)",
89
+ # :rating => 5
90
+ # })
91
+ def create_movie_review(id, options={})
92
+ post "v2/movie/reviews", options
93
+ end
94
+
95
+ # 修改评论
96
+ #
97
+ # @scope douban_basic_common
98
+ # @see http://developers.douban.com/wiki/?title=movie_v2#put_movie_review
99
+ # @authenticated true
100
+ # @param id [String] 评论的id
101
+ # @option options [String] :title 必传
102
+ # @option options [String] :content 必传,且多于150字
103
+ # @option options [Integer] :rating 非必传,数字1~5为合法值,其他信息默认为不打分
104
+ # @return [Hashie::Mash] 电影评论信息
105
+ # @example 修改id为1406334的评论
106
+ # client.edit_movie_review("1406334", {
107
+ # :title => "我们读故事,看电影,不过是因为我们懦弱",
108
+ # :content => "嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻
109
+ # 嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻
110
+ # 嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻...(省略一些嘻)",
111
+ # :rating => 5
112
+ # })
113
+ def edit_movie_review(id, options={})
114
+ put "v2/movie/reviews/#{id}", options
115
+ end
116
+
117
+ # 删除评论
118
+ #
119
+ # @scope douban_basic_common
120
+ # @see http://developers.douban.com/wiki/?title=movie_v2#delete_movie_review
121
+ # @authenticated true
122
+ # @param id [String] 电影的id
123
+ # @return [Boolean] 删除成功则返回true, 否则false
124
+ # @example 删除 id为1406334 电影评论
125
+ # client.remove_movie_review('1406334')
126
+ def remove_movie_review(id)
127
+ begin
128
+ delete "v2/movie/review/#{id}"
129
+ return true
130
+ rescue Douban::NotFound
131
+ return false
132
+ end
133
+ end
134
+
135
+ # 用户对电影的所有标签
136
+ #
137
+ # @scope douban_basic_common
138
+ # @see http://developers.douban.com/wiki/?title=movie_v2#get_people_movie_tags
139
+ # @authenticated false
140
+ # @param user_id [String] 用户的数字id
141
+ # @return [Array<Hashie::Mash>] 标签列表
142
+ # @example 获取数字id为2217855的用户电影收藏的所有标签
143
+ # Douban.user_movie_tags('2217855')
144
+ # @example 获取已认证用户的图书收藏的所有标签
145
+ # client.user_movie_tags
146
+ def user_movie_tags(user_id=nil, options={})
147
+ if user_id.nil?
148
+ response = get("v2/movie/user_tags/#{get_user_id}", options)
149
+ else
150
+ response = get("v2/movie/user_tags/#{user_id}", options)
151
+ end
152
+
153
+ response["tags"]
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,144 @@
1
+ module Douban
2
+ class Client
3
+ # 音乐Api V2 http://developers.douban.com/wiki/?title=music_v2
4
+ module Music
5
+ # 获取音乐信息
6
+ #
7
+ # @see http://developers.douban.com/wiki/?title=music_v2#get_music
8
+ # @scope music_basic_r
9
+ # @authenticated false
10
+ # @param id [String] 音乐的id
11
+ # @return [Hashie::Mash] 音乐信息
12
+ # @example 获取 id为2243497 的音乐信息
13
+ # Douban.music('2243497')
14
+ def music(id)
15
+ response = get "v2/music/#{id}"
16
+ end
17
+
18
+ # 某个音乐中标记最多的标签
19
+ #
20
+ # @scope music_basic_r
21
+ # @see http://developers.douban.com/wiki/?title=music_v2#get_music_tags
22
+ # @authenticated false
23
+ # @param id [String] 音乐的id
24
+ # @return [Array<Hashie::Mash>] 标签的列表
25
+ # @example 获取 id为2243497 的音乐的标记最多的标签
26
+ # Douban.music_tags("2243497")
27
+ def music_tags(id, optins={})
28
+ response = get "v2/music/#{id}/tags", options
29
+ responses["tags"]
30
+ end
31
+
32
+ # 搜索音乐
33
+ #
34
+ # @scope music_basic_r
35
+ # @see http://developers.douban.com/wiki/?title=music_v2#get_music_search
36
+ # @authenticated false
37
+ # @param q [String] 查询关键字
38
+ # @return [Hashie::Mash] 音乐列表
39
+ # @example 搜索音乐 LCD soundsystem 相关的音乐
40
+ # Douban.search_musics("LCD soundsystem")
41
+ def search_music(q, options={})
42
+ response = get "v2/music/search", options.merge(:q => q)
43
+ response["musics"]
44
+ end
45
+
46
+ # 搜索音乐(通过标签)
47
+ #
48
+ # @scope music_basic_r
49
+ # @see http://developers.douban.com/wiki/?title=music_v2#get_music_search
50
+ # @authenticated false
51
+ # @param tag [String] 查询的tag
52
+ # @return [Hashie::Mash] 音乐列表
53
+ # @example 搜索含有标签 post_punk 的音乐
54
+ # Douban.search_music_by_tag("post_punk")
55
+ def search_music_by_tag(tag, options={})
56
+ response = get "v2/music/search", options.merge(:tag => tag)
57
+ response["musics"]
58
+ end
59
+
60
+ # 发表新评论
61
+ #
62
+ # @scope douban_basic_common
63
+ # @see http://developers.douban.com/wiki/?title=music_v2#post_music_review
64
+ # @authenticated true
65
+ # @param id [String] 音乐的id
66
+ # @option options [String] :title 必传
67
+ # @option options [String] :content 必传,且多于150字
68
+ # @option options [Integer] :rating 非必传,数字1~5为合法值,其他信息默认为不打分
69
+ # @return [Hashie::Mash] 音乐评论信息
70
+ # @example 给 id为2243497 的音乐添加评论
71
+ # client.create_music_review("2243497", {
72
+ # :title => "用中枢神经在工地现场弹出印记",
73
+ # :content => "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
74
+ # 哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
75
+ # 哈哈哈哈哈哈哈哈哈哈哈哈...(省略一些哈)",
76
+ # :rating => 5
77
+ # })
78
+ def create_music_review(id, options={})
79
+ post "v2/music/reviews", options
80
+ end
81
+
82
+ # 修改评论
83
+ #
84
+ # @scope douban_basic_common
85
+ # @see http://developers.douban.com/wiki/?title=music_v2#put_music_review
86
+ # @authenticated true
87
+ # @param id [String] 评论的id
88
+ # @option options [String] :title 必传
89
+ # @option options [String] :content 必传,且多于150字
90
+ # @option options [Integer] :rating 非必传,数字1~5为合法值,其他信息默认为不打分
91
+ # @return [Hashie::Mash] 音乐评论信息
92
+ # @example 修改 id为1206396 的评论
93
+ # client.edit_music_review("1206396", {
94
+ # :title => "用中枢神经在工地现场弹出印记",
95
+ # :content => "嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿
96
+ # 嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿
97
+ # 嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿...(省略一些嘿)",
98
+ # :rating => 5
99
+ # })
100
+ def edit_music_review(id, options={})
101
+ put "v2/music/reviews/#{id}", options
102
+ end
103
+
104
+ # 删除评论
105
+ #
106
+ # @scope douban_basic_common
107
+ # @see http://developers.douban.com/wiki/?title=music_v2#delete_music_review
108
+ # @authenticated true
109
+ # @param id [String] 音乐的id
110
+ # @return [Boolean] 删除成功则返回true, 否则false
111
+ # @example 删除 id为2243497 电影评论
112
+ # client.remove_music_review('2243497')
113
+ def remove_music_review(id)
114
+ begin
115
+ delete "v2/music/review/#{id}"
116
+ return true
117
+ rescue Douban::NotFound
118
+ return false
119
+ end
120
+ end
121
+
122
+
123
+ # 用户对音乐的所有标签
124
+ #
125
+ # @scope douban_basic_common
126
+ # @see http://developers.douban.com/wiki/?title=music_v2#get_people_music_tags
127
+ # @authenticated false
128
+ # @param user_id [String] 用户的数字id
129
+ # @return [Array<Hashie::Mash>] 标签列表
130
+ # @example 获取数字id为2217855的用户电影收藏的所有标签
131
+ # Douban.user_music_tags('2217855')
132
+ # @example 获取已认证用户的图书收藏的所有标签
133
+ # client.user_music_tags
134
+ def user_music_tags(user_id=nil, options={})
135
+ if user_id.nil?
136
+ response = get("v2/music/user_tags/#{get_user_id}", options)
137
+ else
138
+ response = get("v2/music/user_tags/#{user_id}", options)
139
+ end
140
+ response["tags"]
141
+ end
142
+ end
143
+ end
144
+ end