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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/easy_weibo/client.rb +33 -0
- data/lib/easy_weibo/version.rb +1 -1
- data/lib/generators/easy_weibo/install_generator.rb +20 -0
- data/lib/generators/templates/initializer.rb +5 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e3f4c79c719a18ffc246bd5e915a099b5dd76c0879bb3ca91828d4478674d4e
|
4
|
+
data.tar.gz: 9059d875f2505052c1b6b2e41500e79b471aa61ef199c872addb919dc5b13a57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e2fd834fcd665d78d1d79c95b063fa135e0a27897c118eba7020e87bff2930902e44cb881b6fe470ef12da1cc0390baaed7647365a5b6b8dff0334f17f19e36
|
7
|
+
data.tar.gz: da1ba584caea797f0ec4633a4e46ea7926ed5137918c890bfd1420d519d38fc714cbc0fb2ef670389dd89e9feb209c5bf8e7fb9ab974d1f42b599bddb2667f7d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/easy_weibo/client.rb
CHANGED
@@ -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
|
data/lib/easy_weibo/version.rb
CHANGED
@@ -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
|
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.
|
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-
|
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:
|