Class: Weibo::Base
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #comment(id, comment, query = {}) ⇒ Object
- #comment_destroy(id) ⇒ Object
- #comments(query = {}) ⇒ Object
- #comments_by_me(query = {}) ⇒ Object
- #comments_timeline(query = {}) ⇒ Object
-
#comments_to_me(query = {}) ⇒ Object
statuses/comments_to_me 当前用户收到的评论.
- #counts(query = {}) ⇒ Object
-
#direct_message_create(user, screen_name, text) ⇒ Object
direct_messages/new 发送私信.
-
#direct_message_destroy(id) ⇒ Object
direct_messages/destroy 删除一条私信.
-
#direct_messages(query = {}) ⇒ Object
direct_messages 我的私信列表 Options: since, since_id, page.
-
#direct_messages_sent(query = {}) ⇒ Object
direct_messages/sent 我发送的私信列表 Options: since, since_id, page.
-
#emotions(query = {}) ⇒ Object
Emotions List of emotions.
-
#end_session(body = {}) ⇒ Object
unimplemented account/end_session 退出.
-
#favorite_create(id) ⇒ Object
favorites/create 添加收藏.
-
#favorite_destroy(id) ⇒ Object
favorites/destroy 删除收藏.
-
#favorites(query = {}) ⇒ Object
favorites 收藏列表 Options: id, page.
-
#follower_ids(query = {}) ⇒ Object
followers/ids 粉丝列表 Options: id, user_id, screen_name.
-
#followers(query = {}) ⇒ Object
statuses/followers 粉丝列表 Options: id, user_id, screen_name, page.
-
#friend_ids(query = {}) ⇒ Object
friends/ids 关注列表 Options: id, user_id, screen_name.
-
#friends(query = {}) ⇒ Object
statuses/friends 关注人列表 Options: id, user_id, screen_name, page.
-
#friends_timeline(query = {}) ⇒ Object
statuses/friends_timeline 最新关注人微博 (别名: statuses/home_timeline) Options: since_id, max_id, count, page, since.
-
#friendship_create(id, follow = false) ⇒ Object
friendships/create 关注某用户.
-
#friendship_destroy(id) ⇒ Object
friendships/destroy 取消关注.
-
#friendship_exists?(a, b) ⇒ Boolean
friendships/exists 是否关注某用户(推荐使用friendships/show).
-
#friendship_show(query) ⇒ Object
friendships/show 是否关注某用户.
- #help ⇒ Object
-
#home_timeline(query = {}) ⇒ Object
Options: since_id, max_id, count, page.
-
#initialize(client) ⇒ Base
constructor
A new instance of Base.
-
#mentions(query = {}) ⇒ Object
statuses/mentions 最新 @用户的 Options: since_id, max_id, count, page.
- #provinces(query = {}) ⇒ Object
-
#public_timeline(query = {}) ⇒ Object
statuses/public_timeline 最新公共微博.
-
#rate_limit_status ⇒ Object
account/rate_limit_status 查看当前频率限制.
-
#replies(query = {}) ⇒ Object
DEPRECATED: Use #mentions instead.
- #reply(comment, query = {}) ⇒ Object
-
#repost(id, status = {}) ⇒ Object
statuses/repost 转发.
-
#reset_count(query = {}) ⇒ Object
statuses/reset_count 未读消息数清零.
-
#retweet(id) ⇒ Object
statuses/repost 转发.
-
#retweets(id, query = { }) ⇒ Object
Options: count.
-
#status(id) ⇒ Object
statuses/show 获取单条.
-
#status_destroy(id) ⇒ Object
statuses/destroy 删除.
- #status_search(q, query = {}) ⇒ Object
-
#tags(query = {}) ⇒ Object
Tags.
-
#tags_create(tags) ⇒ Object
Tags/create params: tags should be a string split with “,”.
-
#tags_destroy(tag_id) ⇒ Object
Tags/destroy.
-
#tags_destroy_batch(ids) ⇒ Object
Tags/destroy_batch.
-
#tags_suggestions(query = {}) ⇒ Object
Tags/suggestions.
- #trends(query = {}) ⇒ Object
-
#trends_daily(query = {}) ⇒ Object
Trends/daily.
-
#trends_destroy(trend_id) ⇒ Object
Trends/destroy.
-
#trends_follow(trend_name) ⇒ Object
Trends/follow.
-
#trends_hourly(query = {}) ⇒ Object
Trends/hourly.
-
#trends_statuses(trend_name, query = {}) ⇒ Object
Trends/statuses.
-
#trends_weekly(query = {}) ⇒ Object
Trends/weekly.
- #unread ⇒ Object
-
#update(status, query = {}) ⇒ Object
-
statuses/update 发表微博 Options: in_reply_to_status_id.
-
-
#update_profile(body = {}) ⇒ Object
account/update_profile 更改资料 One or more of the following must be present: name, email, url, location, description.
-
#update_profile_image(file) ⇒ Object
account/update_profile_image 更改头像 file should respond to #read and #path.
-
#upload(status, file, query = {}) ⇒ Object
statuses/upload 发送带图片的微博,可带地理位置信息 options: status, pic, lat, long.
- #user(id, query = {}) ⇒ Object
- #user_search(q, query = {}) ⇒ Object
- #user_show(query = {}) ⇒ Object
-
#user_timeline(query = {}) ⇒ Object
statuses/user_timeline 用户发表微博列表 Options: id, user_id, screen_name, since_id, max_id, page, since, count.
-
#verify_credentials ⇒ Object
account/verify_credentials 验证身份是否合法.
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
12 13 14 |
# File 'lib/weibo/base.rb', line 12 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/weibo/base.rb', line 10 def client @client end |
Instance Method Details
#comment(id, comment, query = {}) ⇒ Object
108 109 110 |
# File 'lib/weibo/base.rb', line 108 def comment(id, comment, query={}) perform_post("/statuses/comment.json", :body => {:id => id, :comment => comment}.merge(query)) end |
#comment_destroy(id) ⇒ Object
138 139 140 |
# File 'lib/weibo/base.rb', line 138 def comment_destroy(id) perform_post("/statuses/comment_destroy/#{id}.json") end |
#comments(query = {}) ⇒ Object
134 135 136 |
# File 'lib/weibo/base.rb', line 134 def comments(query={}) perform_get('/statuses/comments.json', :query => query) end |
#comments_by_me(query = {}) ⇒ Object
125 126 127 |
# File 'lib/weibo/base.rb', line 125 def comments_by_me(query={}) perform_get('/statuses/comments_by_me.json', :query => query) end |
#comments_timeline(query = {}) ⇒ Object
121 122 123 |
# File 'lib/weibo/base.rb', line 121 def comments_timeline(query={}) perform_get('/statuses/comments_timeline.json', :query => query) end |
#comments_to_me(query = {}) ⇒ Object
statuses/comments_to_me 当前用户收到的评论
130 131 132 |
# File 'lib/weibo/base.rb', line 130 def comments_to_me(query={}) perform_get('/statuses/comments_to_me.json', :query => query) end |
#counts(query = {}) ⇒ Object
65 66 67 |
# File 'lib/weibo/base.rb', line 65 def counts(query={}) perform_get("/statuses/counts.json", :query => query) end |
#direct_message_create(user, screen_name, text) ⇒ Object
direct_messages/new 发送私信
192 193 194 |
# File 'lib/weibo/base.rb', line 192 def (user, screen_name, text) perform_post("/direct_messages/new.json", :body => {:id => user, :screen_name => screen_name, :text => text}) end |
#direct_message_destroy(id) ⇒ Object
direct_messages/destroy 删除一条私信
197 198 199 |
# File 'lib/weibo/base.rb', line 197 def (id) perform_post("/direct_messages/destroy/#{id}.json") end |
#direct_messages(query = {}) ⇒ Object
direct_messages 我的私信列表 Options: since, since_id, page
180 181 182 |
# File 'lib/weibo/base.rb', line 180 def (query={}) perform_get("/direct_messages.json", :query => query) end |
#direct_messages_sent(query = {}) ⇒ Object
direct_messages/sent 我发送的私信列表 Options: since, since_id, page
186 187 188 |
# File 'lib/weibo/base.rb', line 186 def (query={}) perform_get("/direct_messages/sent.json", :query => query) end |
#emotions(query = {}) ⇒ Object
Emotions List of emotions
350 351 352 |
# File 'lib/weibo/base.rb', line 350 def emotions(query={}) perform_get("/emotions.json", :query => query) end |
#end_session(body = {}) ⇒ Object
unimplemented account/end_session 退出
242 243 244 |
# File 'lib/weibo/base.rb', line 242 def end_session(body={}) perform_post('/account/end_session.json') end |
#favorite_create(id) ⇒ Object
favorites/create 添加收藏
273 274 275 |
# File 'lib/weibo/base.rb', line 273 def favorite_create(id) perform_post("/favorites/create/#{id}.json") end |
#favorite_destroy(id) ⇒ Object
favorites/destroy 删除收藏
278 279 280 |
# File 'lib/weibo/base.rb', line 278 def favorite_destroy(id) perform_post("/favorites/destroy/#{id}.json") end |
#favorites(query = {}) ⇒ Object
favorites 收藏列表 Options: id, page
268 269 270 |
# File 'lib/weibo/base.rb', line 268 def favorites(query={}) perform_get('/favorites.json', :query => query) end |
#follower_ids(query = {}) ⇒ Object
followers/ids 粉丝列表 Options: id, user_id, screen_name
231 232 233 |
# File 'lib/weibo/base.rb', line 231 def follower_ids(query={}) perform_get("/followers/ids.json", :query => query, :mash => false) end |
#followers(query = {}) ⇒ Object
statuses/followers 粉丝列表 Options: id, user_id, screen_name, page
165 166 167 |
# File 'lib/weibo/base.rb', line 165 def followers(query={}) perform_get('/statuses/followers.json', :query => query) end |
#friend_ids(query = {}) ⇒ Object
friends/ids 关注列表 Options: id, user_id, screen_name
225 226 227 |
# File 'lib/weibo/base.rb', line 225 def friend_ids(query={}) perform_get("/friends/ids.json", :query => query, :mash => false) end |
#friends(query = {}) ⇒ Object
statuses/friends 关注人列表 Options: id, user_id, screen_name, page
159 160 161 |
# File 'lib/weibo/base.rb', line 159 def friends(query={}) perform_get('/statuses/friends.json', :query => query) end |
#friends_timeline(query = {}) ⇒ Object
statuses/friends_timeline 最新关注人微博 (别名: statuses/home_timeline) Options: since_id, max_id, count, page, since
50 51 52 |
# File 'lib/weibo/base.rb', line 50 def friends_timeline(query={}) perform_get('/statuses/friends_timeline.json', :query => query) end |
#friendship_create(id, follow = false) ⇒ Object
friendships/create 关注某用户
202 203 204 205 206 |
# File 'lib/weibo/base.rb', line 202 def friendship_create(id, follow=false) body = {} body.merge!(:follow => follow) if follow perform_post("/friendships/create/#{id}.json", :body => body) end |
#friendship_destroy(id) ⇒ Object
friendships/destroy 取消关注
209 210 211 |
# File 'lib/weibo/base.rb', line 209 def friendship_destroy(id) perform_delete("/friendships/destroy/#{id}.json") end |
#friendship_exists?(a, b) ⇒ Boolean
friendships/exists 是否关注某用户(推荐使用friendships/show)
214 215 216 |
# File 'lib/weibo/base.rb', line 214 def friendship_exists?(a, b) perform_get("/friendships/exists.json", :query => {:user_a => a, :user_b => b}) end |
#friendship_show(query) ⇒ Object
friendships/show 是否关注某用户
219 220 221 |
# File 'lib/weibo/base.rb', line 219 def friendship_show(query) perform_get("/friendships/show.json", :query => query) end |
#help ⇒ Object
282 283 284 |
# File 'lib/weibo/base.rb', line 282 def help perform_get('/help/test.json') end |
#home_timeline(query = {}) ⇒ Object
Options: since_id, max_id, count, page
43 44 45 |
# File 'lib/weibo/base.rb', line 43 def home_timeline(query={}) perform_get('/statuses/home_timeline.json', :query => query) end |
#mentions(query = {}) ⇒ Object
statuses/mentions 最新 @用户的 Options: since_id, max_id, count, page
91 92 93 |
# File 'lib/weibo/base.rb', line 91 def mentions(query={}) perform_get('/statuses/mentions.json', :query => query) end |
#provinces(query = {}) ⇒ Object
16 17 18 |
# File 'lib/weibo/base.rb', line 16 def provinces(query={}) perform_get('/provinces.json', :query => query) end |
#public_timeline(query = {}) ⇒ Object
statuses/public_timeline 最新公共微博
37 38 39 |
# File 'lib/weibo/base.rb', line 37 def public_timeline(query = {}) perform_get('/statuses/public_timeline.json', :query => query) end |
#rate_limit_status ⇒ Object
account/rate_limit_status 查看当前频率限制
255 256 257 |
# File 'lib/weibo/base.rb', line 255 def rate_limit_status perform_get('/account/rate_limit_status.json') end |
#replies(query = {}) ⇒ Object
DEPRECATED: Use #mentions instead
Options: since_id, max_id, since, page statuses/mentions 最新 @用户的
84 85 86 87 |
# File 'lib/weibo/base.rb', line 84 def replies(query={}) warn("DEPRECATED: #replies is deprecated by Twitter; use #mentions instead") perform_get('/statuses/mentions.json', :query => query) end |
#reply(comment, query = {}) ⇒ Object
104 105 106 |
# File 'lib/weibo/base.rb', line 104 def reply(comment, query={}) perform_post("/statuses/reply.json", :body => {:comment => comment}.merge(query)) end |
#repost(id, status = {}) ⇒ Object
statuses/repost 转发
153 154 155 |
# File 'lib/weibo/base.rb', line 153 def repost(id, status={}) perform_post("/statuses/repost.json", :body => {:id => id}.merge(status)) end |
#reset_count(query = {}) ⇒ Object
statuses/reset_count 未读消息数清零
117 118 119 |
# File 'lib/weibo/base.rb', line 117 def reset_count(query={}) perform_get('/statuses/reset_count.json', :query => query) end |
#retweet(id) ⇒ Object
statuses/repost 转发
148 149 150 |
# File 'lib/weibo/base.rb', line 148 def retweet(id) perform_post("/statuses/repost/#{id}.json") end |
#retweets(id, query = { }) ⇒ Object
Options: count
70 71 72 |
# File 'lib/weibo/base.rb', line 70 def retweets(id, query={ }) perform_get("/statuses/retweets/#{id}.json", :query => query) end |
#status(id) ⇒ Object
statuses/show 获取单条
61 62 63 |
# File 'lib/weibo/base.rb', line 61 def status(id) perform_get("/statuses/show/#{id}.json") end |
#status_destroy(id) ⇒ Object
statuses/destroy 删除
143 144 145 |
# File 'lib/weibo/base.rb', line 143 def status_destroy(id) perform_post("/statuses/destroy/#{id}.json") end |
#status_search(q, query = {}) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/weibo/base.rb', line 20 def status_search(q, query={}) q = URI.escape(q) if q != "" query = {:q => q}.merge(query) end perform_get('/statuses/search.json', :query => query) end |
#tags(query = {}) ⇒ Object
Tags
323 324 325 |
# File 'lib/weibo/base.rb', line 323 def (query={}) perform_get("/tags.json", :query => query) end |
#tags_create(tags) ⇒ Object
Tags/create params: tags should be a string split with “,”
329 330 331 |
# File 'lib/weibo/base.rb', line 329 def () perform_post("/tags/create.json", :body => {:tags => }) end |
#tags_destroy(tag_id) ⇒ Object
Tags/destroy
339 340 341 |
# File 'lib/weibo/base.rb', line 339 def (tag_id) perform_delete("/tags/destroy.json", :body => {:tag_id => tag_id}) end |
#tags_destroy_batch(ids) ⇒ Object
Tags/destroy_batch
344 345 346 |
# File 'lib/weibo/base.rb', line 344 def (ids) perform_delete("/tags/destroy_batch.json", :body => {:ids => ids}) end |
#tags_suggestions(query = {}) ⇒ Object
Tags/suggestions
334 335 336 |
# File 'lib/weibo/base.rb', line 334 def (query={}) perform_get("/tags/suggestions.json", :query => query) end |
#trends(query = {}) ⇒ Object
286 287 288 |
# File 'lib/weibo/base.rb', line 286 def trends(query = {}) perform_get("/trends.json", :query => query) end |
#trends_daily(query = {}) ⇒ Object
Trends/daily
296 297 298 |
# File 'lib/weibo/base.rb', line 296 def trends_daily(query={}) perform_get("/trends/daily.json", :query => query) end |
#trends_destroy(trend_id) ⇒ Object
Trends/destroy
318 319 320 |
# File 'lib/weibo/base.rb', line 318 def trends_destroy(trend_id) perform_delete("/trends/destroy.json", :query => {:trend_id => trend_id}) end |
#trends_follow(trend_name) ⇒ Object
Trends/follow
313 314 315 |
# File 'lib/weibo/base.rb', line 313 def trends_follow(trend_name) perform_post("/trends/follow.json", :body => {:trend_name => trend_name}) end |
#trends_hourly(query = {}) ⇒ Object
Trends/hourly
291 292 293 |
# File 'lib/weibo/base.rb', line 291 def trends_hourly(query={}) perform_get("/trends/hourly.json", :query => query) end |
#trends_statuses(trend_name, query = {}) ⇒ Object
Trends/statuses
306 307 308 309 310 |
# File 'lib/weibo/base.rb', line 306 def trends_statuses(trend_name, query={}) body = {:trend_name => trend_name} body.merge!(query) perform_post("/trends/statuses.json", :body => body) end |
#trends_weekly(query = {}) ⇒ Object
Trends/weekly
301 302 303 |
# File 'lib/weibo/base.rb', line 301 def trends_weekly(query={}) perform_get("/trends/weekly.json", :query => query) end |
#unread ⇒ Object
112 113 114 |
# File 'lib/weibo/base.rb', line 112 def unread perform_get('/statuses/unread.json') end |
#update(status, query = {}) ⇒ Object
-
statuses/update 发表微博
Options: in_reply_to_status_id
76 77 78 |
# File 'lib/weibo/base.rb', line 76 def update(status, query={}) perform_post("/statuses/update.json", :body => {:status => status}.merge(query)) end |
#update_profile(body = {}) ⇒ Object
account/update_profile 更改资料 One or more of the following must be present:
name, email, url, location, description
262 263 264 |
# File 'lib/weibo/base.rb', line 262 def update_profile(body={}) perform_post('/account/update_profile.json', :body => body) end |
#update_profile_image(file) ⇒ Object
account/update_profile_image 更改头像 file should respond to #read and #path
248 249 250 251 252 |
# File 'lib/weibo/base.rb', line 248 def update_profile_image(file) PostBodyHack.apply_hack do perform_post('/account/update_profile_image.json', build_multipart_bodies(:image => file)) end end |
#upload(status, file, query = {}) ⇒ Object
statuses/upload 发送带图片的微博,可带地理位置信息 options: status, pic, lat, long
98 99 100 101 102 |
# File 'lib/weibo/base.rb', line 98 def upload(status, file, query={}) PostBodyHack.apply_hack({:status => status}.merge(query)) do perform_post("/statuses/upload.json", build_multipart_bodies({:pic => file, :status => status}.merge(query))) end end |
#user(id, query = {}) ⇒ Object
169 170 171 |
# File 'lib/weibo/base.rb', line 169 def user(id, query={}) perform_get("/users/show/#{id}.json", :query => query) end |
#user_search(q, query = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/weibo/base.rb', line 28 def user_search(q, query={}) q = URI.escape(q) if q != "" query = {:q => q}.merge(query) end perform_get('/users/search.json', :query => query) end |
#user_show(query = {}) ⇒ Object
173 174 175 |
# File 'lib/weibo/base.rb', line 173 def user_show(query={}) perform_get("/users/show.json", :query => query) end |
#user_timeline(query = {}) ⇒ Object
statuses/user_timeline 用户发表微博列表 Options: id, user_id, screen_name, since_id, max_id, page, since, count
56 57 58 |
# File 'lib/weibo/base.rb', line 56 def user_timeline(query={}) perform_get('/statuses/user_timeline.json', :query => query) end |
#verify_credentials ⇒ Object
account/verify_credentials 验证身份是否合法
236 237 238 |
# File 'lib/weibo/base.rb', line 236 def verify_credentials perform_get("/account/verify_credentials.json") end |