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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: affaaa50b4deabbdd3133a09a380b2d84295e5c9477536973b68f325f0989d8e
4
- data.tar.gz: 49f7ff6ce7770d66d2e6eb51914ae894f832f87c50fb14d62cada4d2456d327c
3
+ metadata.gz: 1669972201f19743b30a27a745c3cd37b08f0f7b6a04cf6900fbcb5a1c78ad99
4
+ data.tar.gz: 7cdf5afa1d2ff3e1d4b3e3b168389720396c140b9905522474716d1260d7f1c7
5
5
  SHA512:
6
- metadata.gz: ff3fddc940bed86a5d79ea14a159288bbcf6d453f4bb3cc5dfecbc57cf68ff4e1573dd6f7c4fdea1a1fd86ed5cced4a8a9b0f522820ca6b109ded29b4446060a
7
- data.tar.gz: 3a820257d4609d129d9866a788d4e9a3f41e3e9ec7d6d0f387a39be0e4beb67b4b3afa6e837a00a9833a7fd9eb3face7bb138a65fa9305dd2cc06651ed24b9df
6
+ metadata.gz: 2a63444188f5ab75a417722d37b0b7bd7e2e43556b157fbfdd6e7e0a455f8b39037f45fb6adf1cabdfe4c097fd6c4ac9e4b90ba0035d580b46c6c0234c938e3a
7
+ data.tar.gz: 132c104462bf195f1c4eb34d1bfa7cb0fe85a846a59468b723233ee2de28fe7eb4cf595061d64920898c68d6e99d58de3653d85e52ec48ae9f5729ff62572624
@@ -0,0 +1 @@
1
+ .idea/
@@ -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
- @client_key = client_secret
19
+ @client_secret = client_secret
18
20
  end
19
21
 
20
22
 
@@ -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
- action = '/platform/oauth/connect/'
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
- action = '/oauth/access_token/'
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
- action = '/oauth/refresh_token/'
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
 
@@ -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
- action = '/oauth/userinfo/'
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
- action = '/fans/list/'
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
 
@@ -1,3 +1,3 @@
1
1
  module DouyinSdk
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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
- action = '/video/list/'
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
- action = '/video/data/'
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.0
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-15 00:00:00.000000000 Z
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