-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTikTokClient.py
197 lines (180 loc) · 6.93 KB
/
TikTokClient.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/usr/bin/python
# -*- coding: utf-8 -*-
# TikTok Premium API client.
#
# TERMS OF USE:
# - This code is in no way affiliated with, authorized, maintained, sponsored
# or endorsed by TikTok or any of its affiliates or subsidiaries. This is
# an independent and unofficial API. Use at your own risk.
# - We do NOT support or tolerate anyone who wants to use this API to send spam
# or commit other online crimes.
# - You will NOT use this API for marketing or other abusive purposes (spam,
# botting, harassment, massive bulk messaging...). For education purposes
# only.
#
# @author revpy200, [email protected]
import requests as r
class TikTokApiClient:
protocol = "http"
host = "localhost"
port = 4444
base_url = protocol + "://" + host + ":" + str(port)
tok_proxy = ""
api_token = ""
def __init__(self, proxy, token) -> None:
self.tok_proxy = proxy
self.api_token = token
def device_register(self):
path = "/device-register"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def account_register(self, install_id, device_id, openudid, operator_id, email, password):
path = "/account-register"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'email': email,
'password': password
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def account_register_verify_code(self, install_id, device_id, openudid, operator_id, email, password, code):
path = "/register-verify-code"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'email': email,
'password': password,
'code' : str(code)
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def account_register_verify_age(self, install_id, device_id, openudid, operator_id, birthday):
path = "/register-verify-age"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'birthday': birthday
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def account_register_verify_email_registered(self, install_id, device_id, openudid, operator_id, email):
path = "/register-verify-email-registered"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'email': email
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def account_login_username(self, install_id, device_id, openudid, operator_id, username, password):
path = "/login-username"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'username': username,
'password' : password
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def account_login_email(self, install_id, device_id, openudid, operator_id, email, password):
path = "/login-email"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'email': email,
'password' : password
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def post_like(self, install_id, device_id, openudid, operator_id, aweme_id, cookie, uid):
path = "/like-post"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'aweme_id': str(aweme_id),
'cookie': cookie,
'uid': str(uid)
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def post_comment(self, install_id, device_id, openudid, operator_id, aweme_id, text, cookie, uid):
path = "/post-comment"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'aweme_id': str(aweme_id),
'text' : text,
'cookie': cookie,
'uid': str(uid)
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def user_follow(self, install_id, device_id, openudid, operator_id, sec_userid, user_id, cookie, uid):
path = "/follow-user"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'sec_userid': str(sec_userid),
'user_id': str(user_id),
'cookie': cookie,
'uid': str(uid)
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)
def user_unfollow(self, install_id, device_id, openudid, operator_id, sec_userid, user_id, cookie, uid):
path = "/unfollow-user"
payload={}
headers = {
'tok-proxy': self.tok_proxy,
'api-token': self.api_token,
'install-id': install_id,
'device-id': device_id,
'openudid': openudid,
'operator-id': operator_id,
'sec_userid': str(sec_userid),
'user_id': str(user_id),
'cookie': cookie,
'uid': str(uid)
}
return r.post("GET", self.base_url + path, headers=headers, data=payload)