easy_weibo 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bb2c8cf7bed11a3a9c6c3bb4dae6e37e9b3ed2e5750cc35a27f8a15a11ada3a
4
- data.tar.gz: c8f038576af0cbd93c73a6e36a324e0f9a9d99e684765b6085c6432622e891b4
3
+ metadata.gz: 8e3f4c79c719a18ffc246bd5e915a099b5dd76c0879bb3ca91828d4478674d4e
4
+ data.tar.gz: 9059d875f2505052c1b6b2e41500e79b471aa61ef199c872addb919dc5b13a57
5
5
  SHA512:
6
- metadata.gz: d2a6c3b26eb2e882cca777e2e1b92155c5012b4ba4d72f904a20e7dddcc8b826cd8178c282ca3a0cb24f181fd46528e813694a944054f5b5c934397a697d7d5a
7
- data.tar.gz: 4f18234cb0c62d9326c6bb973705884da19b0960d1d9f34537218a4f0cb80ce31a09e77f81b60ffda4f7bd5a436188439aba9f751a13fef10ec2fe343381b5a0
6
+ metadata.gz: 9e2fd834fcd665d78d1d79c95b063fa135e0a27897c118eba7020e87bff2930902e44cb881b6fe470ef12da1cc0390baaed7647365a5b6b8dff0334f17f19e36
7
+ data.tar.gz: da1ba584caea797f0ec4633a4e46ea7926ed5137918c890bfd1420d519d38fc714cbc0fb2ef670389dd89e9feb209c5bf8e7fb9ab974d1f42b599bddb2667f7d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_weibo (0.1.0)
4
+ easy_weibo (0.1.1)
5
5
  activesupport
6
6
  http-form_data
7
7
  httpx
data/README.md CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
  ```
25
+ rails g easy_wechat:install
26
+
25
27
  EasyWeibo.configure do |config|
26
28
  config.app_key = ""
27
29
  config.app_secret = ""
@@ -8,6 +8,8 @@ module EasyWeibo
8
8
  OAUTH2_AUTHORIZE_URL = "https://api.weibo.com/oauth2/authorize"
9
9
  OAUTH2_ACCESS_TOKEN_URL = "https://api.weibo.com/oauth2/access_token"
10
10
  STATUSES_SHARE_URL = "https://api.weibo.com/2/statuses/share.json"
11
+ USER_TIMELINE_URL = "https://api.weibo.com/2/statuses/user_timeline.json"
12
+ USERS_SHOW_URL = "https://api.weibo.com/2/users/show.json"
11
13
 
12
14
  attr_writer :token, :code
13
15
 
@@ -61,5 +63,36 @@ module EasyWeibo
61
63
  yield r if block_given?
62
64
  r
63
65
  end
66
+
67
+ # https://open.weibo.com/wiki/2/statuses/user_timeline
68
+ def user_timeline(uid, options = {})
69
+ params = {
70
+ access_token: token,
71
+ uid: uid,
72
+ since_id: options.delete(:since_id) || 0, # 若指定此参数,则返回ID比since_id大的微博(即比时间晚的微博),默认为0。
73
+ max_id: options.delete(:max_id) || 0, # 若指定此参数,则返回ID小于或等于max_id的微博,默认为0。
74
+ count: options.delete(:count) || 20, # 单页返回的记录条数,最大不超过100,超过100以100处理,默认为20。
75
+ page: options.delete(:page) || 1, # 返回结果的页码,默认为1。
76
+ base_app: options.delete(:base_app) || 0, # 是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。
77
+ feature: options.delete(:feature) || 0, # 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。
78
+ trim_user: options.delete(:trim_user) || 0, # 返回值中user字段开关,0:返回完整user字段、1:user字段仅返回user_id,默认为0。
79
+ }
80
+
81
+ resp = HTTPX.get(USER_TIMELINE_URL, params: params)
82
+
83
+ r = ::JSON.parse(resp.body, quirks_mode: true)
84
+ yield r if block_given?
85
+ r
86
+ end
87
+
88
+ def users_show(uid)
89
+ params = { uid: uid, access_token: token }
90
+
91
+ resp = HTTPX.get(USERS_SHOW_URL, params: params)
92
+
93
+ r = ::JSON.parse(resp.body, quirks_mode: true)
94
+ yield r if block_given?
95
+ r
96
+ end
64
97
  end
65
98
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasyWeibo
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -0,0 +1,20 @@
1
+ module EasyWeibo
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "EasyWeibo installation: initializer"
5
+ source_root File.expand_path("../../templates", __FILE__)
6
+
7
+ def install
8
+ puts "==> generate initializer file ..."
9
+ copy_initializer
10
+ puts "Done!"
11
+ end
12
+
13
+ private
14
+
15
+ def copy_initializer
16
+ template "initializer.rb", "config/initializers/easy_weibo.rb"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ EasyWeibo.configure do |config|
2
+ # config.app_key = ENV.fetch("APP_KEY") || ""
3
+ # config.app_secret = ENV.fetch("APP_SECRET") || ""
4
+ # config.redirect_uri = ENV.fetch("APP_REDIRECT_URI") || ""
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_weibo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-12 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpx
@@ -131,6 +131,8 @@ files:
131
131
  - lib/easy_weibo/client.rb
132
132
  - lib/easy_weibo/configuration.rb
133
133
  - lib/easy_weibo/version.rb
134
+ - lib/generators/easy_weibo/install_generator.rb
135
+ - lib/generators/templates/initializer.rb
134
136
  - test.jpg
135
137
  homepage: https://github.com/42up/easy_weibo
136
138
  licenses: