Closed rocailler closed 4 years ago
Issue-Label Bot is automatically applying the label bug
to this issue, with a confidence of 0.96. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
It seems to be a larger issue
Tests Failing
Endpoint discoverHashtags still works, but yes byHashtag got exception error.
{'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', 'accept-encoding': 'gzip, deflate, br', 'accept': 'application/json, text/plain, */*', 'Connection': 'keep-alive', 'authority': 'm.tiktok.com', 'method': 'GET', 'path': '/share/item/list?aid=1988&app_name=tiktok_web&device_platform=web&referer=&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F84.0.4147.125+Safari%2F537.36&cookie_enabled=true&screen_width=800&screen_height=600&browser_language=&browser_platform=&browser_name=&browser_version=&browser_online=true&timezone_name=&priority_region=&appId=1233&appType=m&isAndroid=false&isMobile=false&isIOS=false&OS=windows&did=145410044®ion=US&secUid=&id=62520&type=3&count=300&minCursor=0&maxCursor=0&shareUid=&recType=&lang=id&verifyFp=DFAQEbKvEsBdxSvt&_signature=_02B4Z6wo00f01orqPowAAIBAs-JmTEY6BGqK-joAAP3-00', 'scheme': 'https', 'accept-language': 'en-US,en;q=0.9', 'referrer': 'https:/www.tiktok.com/', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site'}
Converting response to JSON failed response is below (probably empty)
2020-09-07 08:49:50,218 tiktok [31741] [ERROR] ERROR-2 Invalid Response
Traceback (most recent call last):
File "/home/tiktok/.venv_py36/lib/python3.6/site-packages/TikTokApi/tiktok.py", line 85, in getData
return r.json()
File "/home/tiktok/.venv_py36/lib/python3.6/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tiktok/tiktok.py", line 245, in <module>
tk_agent.start()
File "/home/tiktok/tiktok.py", line 232, in start
self.by_hashtag(hashtag=kwd, count=self.post_per_request)
File "/home/tiktok/tiktok.py", line 125, in by_hashtag
posts = self.api.byHashtag(hashtag=hashtag, count=count, language='id')
File "/home/tiktok/.venv_py36/lib/python3.6/site-packages/TikTokApi/tiktok.py", line 357, in byHashtag
res = self.getData(api_url, b, proxy=proxy, language=language)
File "/home/tiktok/.venv_py36/lib/python3.6/site-packages/TikTokApi/tiktok.py", line 91, in getData
raise Exception('Invalid Response')
Exception: Invalid Response
@davidteather can you share with us possible reasons for this error ? so we can work together to fix it? I am using your TikTok-Api , and using ur interface where i choose 2(for 5-7 min video) and then 2(for hashtag). Thanks!
There seems to be some API changes for these endpoints.
For example for hashtag endpoint, there are two new(?) parameters:
priority_region
(e.g. TH
for Thailand)tt-web-region
(e.g. TH
for Thailand) user_language
parameter seems to be gone now.max_cursor
maxCursor
kinda seems to be required to have a proper value now (?), i.e. even for first pageCompared to what I see in chrome devtools.
@Granitosaurus here is the URL of the calls from a guest window. Everything you said seems right. Also, it's maxCursor
, not max_cursor
.
https://m.tiktok.com/share/item/list?aid=1988&app_name=tiktok_web&device_platform=web&referer=&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=en-US&browser_platform=Win32&browser_name=Mozilla&browser_version=5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&browser_online=true&ac=4g&timezone_name=America%2FNew_York&priority_region=&appId=1233®ion=US&appType=m&isAndroid=false&isMobile=false&isIOS=false&OS=windows&did=6869796811135485445&secUid=&id=229207&type=3&count=30&minCursor=0&maxCursor=0&shareUid=&recType=&lang=&verifyFp=verify_kessja7g_BCk1nsDe_YsYQ_4hyP_9bGX_fj1ypHrqLwx0&_signature=_02B4Z6wo00f01YYw7LgAAIBBwNHmb-qJuVWGMegAAD7ec2
Scrolling down:
https://m.tiktok.com/share/item/list?aid=1988&app_name=tiktok_web&device_platform=web&referer=&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=en-US&browser_platform=Win32&browser_name=Mozilla&browser_version=5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&browser_online=true&ac=4g&timezone_name=America%2FNew_York&priority_region=&appId=1233®ion=US&appType=m&isAndroid=false&isMobile=false&isIOS=false&OS=windows&did=6869796811135485445&secUid=&id=229207&type=3&count=30&minCursor=0&maxCursor=30&shareUid=&recType=&lang=&verifyFp=verify_kessja7g_BCk1nsDe_YsYQ_4hyP_9bGX_fj1ypHrqLwx0&_signature=_02B4Z6wo00d015LyXQAAAIBD1BNX1sp3Sg-S81mAALv215
Thanks for the information, I didn’t have much time to investigate the issue last night. I’ll try to get some more work done on it tonight
The one thing that is concerning to me is that if you open the request that your browser makes to TikTok in another tab you're given an authorization failed error. I imagine it has to do with the cookies. I'm going to look into it further, but one of my guesses it is the tt_webid_v2 cookie needs to be present as the value of that is also the did parameter in the URL requests
David, I've suggested a fix to the issue. apparently Tiktok decided to check the "Referer" header and it was written as "referrer" in the code. for everyone that need a quick fix like me, just change it on line 76 (tiktok.py)
@WinkyDev Thank you so much! It seems to be working now. I'll publish a package when the tests start to pass
Since yesterday i have a problem with few endpoints. I've tested only getby endpoints and byHashtag and by Sound have responses 403
is this a bigger problem or something went wrong on my project?
Desktop: