douyin_sdk 0.1.0 → 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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/douyin_sdk/client.rb +3 -1
- data/lib/douyin_sdk/oauth.rb +6 -6
- data/lib/douyin_sdk/user.rb +4 -4
- data/lib/douyin_sdk/version.rb +1 -1
- data/lib/douyin_sdk/video.rb +4 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1669972201f19743b30a27a745c3cd37b08f0f7b6a04cf6900fbcb5a1c78ad99
|
4
|
+
data.tar.gz: 7cdf5afa1d2ff3e1d4b3e3b168389720396c140b9905522474716d1260d7f1c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a63444188f5ab75a417722d37b0b7bd7e2e43556b157fbfdd6e7e0a455f8b39037f45fb6adf1cabdfe4c097fd6c4ac9e4b90ba0035d580b46c6c0234c938e3a
|
7
|
+
data.tar.gz: 132c104462bf195f1c4eb34d1bfa7cb0fe85a846a59468b723233ee2de28fe7eb4cf595061d64920898c68d6e99d58de3653d85e52ec48ae9f5729ff62572624
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea/
|
data/lib/douyin_sdk/client.rb
CHANGED
@@ -8,13 +8,15 @@ module DouyinSdk
|
|
8
8
|
class Client
|
9
9
|
|
10
10
|
include Oauth
|
11
|
+
include User
|
12
|
+
include Video
|
11
13
|
|
12
14
|
attr_accessor :client_key, :client_secret, :scope # Time.now + expires_in
|
13
15
|
# attr_accessor :access_token
|
14
16
|
|
15
17
|
def initialize(client_key, client_secret)
|
16
18
|
@client_key = client_key
|
17
|
-
@
|
19
|
+
@client_secret = client_secret
|
18
20
|
end
|
19
21
|
|
20
22
|
|
data/lib/douyin_sdk/oauth.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module DouyinSdk
|
3
3
|
module Oauth
|
4
|
+
OAUTH_CONNECT = '/platform/oauth/connect/'
|
5
|
+
ACCESS_TOKEN = '/oauth/access_token/'
|
6
|
+
REFRESH_TOKEN = '/oauth/refresh_token/'
|
4
7
|
|
5
8
|
#获取授权连接
|
6
9
|
def auth_code_url(redirect_uri, scope="user_info")
|
7
|
-
|
8
|
-
DouyinSdk.endpoint_url(action + "?client_key=#{client_key}&response_type=code&scope=#{scope}&redirect_uri=#{redirect_uri}")
|
10
|
+
DouyinSdk.endpoint_url(OAUTH_CONNECT + "?client_key=#{client_key}&response_type=code&scope=#{scope}&redirect_uri=#{redirect_uri}")
|
9
11
|
end
|
10
12
|
|
11
13
|
#获取access_token
|
12
14
|
def access_token(code)
|
13
|
-
|
14
|
-
res = Typhoeus.post(DouyinSdk.endpoint_url(action + "?client_key=#{client_key}&client_secret=#{client_secret}&code=#{code}&grant_type=authorization_code"))
|
15
|
+
res = Typhoeus.post(DouyinSdk.endpoint_url(ACCESS_TOKEN + "?client_key=#{client_key}&client_secret=#{client_secret}&code=#{code}&grant_type=authorization_code"))
|
15
16
|
JSON.parse(res.body)
|
16
17
|
end
|
17
18
|
|
18
19
|
#刷新access_token
|
19
20
|
def refresh_token(refresh_token)
|
20
|
-
|
21
|
-
res = Typhoeus.get(DouyinSdk.endpoint_url(action + "?refresh_token=#{refresh_token}&client_key=#{CLIENT_KEY}&grant_type=refresh_token"))
|
21
|
+
res = Typhoeus.get(DouyinSdk.endpoint_url(REFRESH_TOKEN + "?refresh_token=#{refresh_token}&client_key=#{client_key}&grant_type=refresh_token"))
|
22
22
|
JSON.parse(res.body)
|
23
23
|
end
|
24
24
|
|
data/lib/douyin_sdk/user.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module DouyinSdk
|
3
3
|
module User
|
4
|
+
USER_INFO = '/oauth/userinfo/'
|
5
|
+
FAN_LIST = '/fans/list/'
|
4
6
|
|
5
7
|
#获取用户信息
|
6
8
|
def user_info(access_token, open_id)
|
7
|
-
|
8
|
-
res = Typhoeus.post(DouyinSdk.endpoint_url(action + "?access_token=#{access_token}&open_id=#{open_id}"))
|
9
|
+
res = Typhoeus.post(DouyinSdk.endpoint_url(USER_INFO + "?access_token=#{access_token}&open_id=#{open_id}"))
|
9
10
|
JSON.parse(res.body)
|
10
11
|
end
|
11
12
|
|
12
13
|
#获取粉丝列表
|
13
14
|
def fan_list(access_token, open_id, count = 10, cursor = 0)
|
14
|
-
|
15
|
-
res = Typhoeus.post(DouyinSdk.endpoint_url(action + "?access_token=#{access_token}&open_id=#{open_id}&count=#{count}&cursor=#{cursor}"))
|
15
|
+
res = Typhoeus.post(DouyinSdk.endpoint_url(FAN_LIST + "?access_token=#{access_token}&open_id=#{open_id}&count=#{count}&cursor=#{cursor}"))
|
16
16
|
JSON.parse(res.body)
|
17
17
|
end
|
18
18
|
|
data/lib/douyin_sdk/version.rb
CHANGED
data/lib/douyin_sdk/video.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module DouyinSdk
|
3
3
|
module Video
|
4
|
+
VIDEO_LIST = '/video/list/'
|
5
|
+
VIDEO_DATA = '/video/data/'
|
4
6
|
|
5
7
|
#获取用户视频列表
|
6
8
|
def video_list(access_token, open_id, count = 10, cursor = 0)
|
7
|
-
|
8
|
-
res = Typhoeus.get(DouyinSdk.endpoint_url(action + "?access_token=#{access_token}&open_id=#{open_id}&count=#{count}&cursor=#{cursor}"))
|
9
|
+
res = Typhoeus.get(DouyinSdk.endpoint_url(VIDEO_LIST + "?access_token=#{access_token}&open_id=#{open_id}&count=#{count}&cursor=#{cursor}"))
|
9
10
|
JSON.parse(res.body)
|
10
11
|
end
|
11
12
|
|
12
13
|
#查询指定视频数据
|
13
14
|
def video_data(access_token, open_id, item_id)
|
14
|
-
|
15
|
-
res = Typhoeus.post(DouyinSdk.endpoint_url(action + "?access_token=#{access_token}&open_id=#{open_id}"), headers: {'Content-Type': 'application/json'}, body: {item_ids: [item_id] }.to_json)
|
15
|
+
res = Typhoeus.post(DouyinSdk.endpoint_url(VIDEO_DATA + "?access_token=#{access_token}&open_id=#{open_id}"), headers: {'Content-Type': 'application/json'}, body: {item_ids: [item_id] }.to_json)
|
16
16
|
JSON.parse(res.body)
|
17
17
|
end
|
18
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: douyin_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dhuSaverin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".gitignore"
|
76
77
|
- Gemfile
|
77
78
|
- LICENSE.txt
|
78
79
|
- README.md
|