Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - TikTok sent invalid JSON back #392

Closed
JohnTYH opened this issue Nov 24, 2020 · 9 comments
Closed

[BUG] - TikTok sent invalid JSON back #392

JohnTYH opened this issue Nov 24, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@JohnTYH
Copy link

JohnTYH commented Nov 24, 2020

Read Below!!! If this doesn't fix your issue delete these two lines

You may need to install chromedriver for your machine globally. Download it here and add it to your path.

Describe the bug
TikTok sent invalid JSON back.

The buggy code

Please insert the code that is throwing errors or is giving you weird unexpected results.

from TikTokApi import TikTokApi
import random
import os
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
did = str(random.randint(10000, 999999999))
t = api.byUsername('therock', did=did, custom_verifyFp='your_verify_fp')[0]
print(t)
v_bytes = api.get_Video_By_TikTok(t, did=did, custom_verifyFp='your_verify_fp')
with open("test.mp4", 'wb') as o:
    o.write(v_bytes)

Expected behavior

A clear and concise description of what you expected to happen.

Error Trace (if any)

Put the error trace below if there's any error thrown.

# Error Trace Here

ERROR:root:TikTok response: illegal request...
ERROR:root:Converting response to JSON failed
ERROR:root:Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py", line 173, in getData
json = r.json()
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\requests\models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "temp.py", line 6, in
t = api.byUsername('therock', did=did, custom_verifyFp='your_verify_fp')[0]
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py", line 493, in byUsername
**kwargs,
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py", line 451, in userPosts
res = self.getData(url=api_url, **kwargs)
File "C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py", line 191, in getData
raise JSONDecodeFailure() from e
TikTokApi.exceptions.JSONDecodeFailure: TikTok sent invalid JSON back

Desktop (please complete the following information):

  • OS: [e.g. Windows 10]
  • TikTokApi Version [e.g. 3.3.1] - 3.8.1

Additional context
Referred to #374 for bugfix.
Add any other context about the problem here.

@JohnTYH JohnTYH added the bug Something isn't working label Nov 24, 2020
@thanhnguyen1121
Copy link

TikTok had add verrification in web. You need verrifyFp to get data.

@JohnTYH
Copy link
Author

JohnTYH commented Nov 25, 2020

Hmm, could you give me an example of how to include the verifyFp? Ive been looking through this repo but im still not sure...

@thanhnguyen1121
Copy link

I don't know how to get it in python. But when I decode tiktok in web after confirming, I get an api like this: "https://www.tiktok.com/node/share/user/@your_tiktok_username?verifyFp=verify_khwsg04i_Kjx9V5Ev_u6d2_4UiG_8p2n_LAsK5DB"

@ek8terina
Copy link

ek8terina commented Nov 25, 2020

I logged into TikTok on chrome and then got the s_v_web_id value in cookies (on chrome go into settings, see all cookies, and you can find the s_v_web_id value there it just a long string like verify_*********...). I used that in for custom_verifyFp="", but still keep getting the same exact JSON error, my same code worked a few weeks ago so I assume I'm doing something wrong with the way I'm using verifyFp, but idk...

@KennBro
Copy link

KennBro commented Nov 25, 2020

Same

@demon071
Copy link

I don't know how to get it in python. But when I decode tiktok in web after confirming, I get an api like this: "https://www.tiktok.com/node/share/user/@your_tiktok_username?verifyFp=verify_khwsg04i_Kjx9V5Ev_u6d2_4UiG_8p2n_LAsK5DB"

Not bad idea, I'll try it

@davidteather
Copy link
Owner

Yeah the verifyFp you can view as a parameter on API calls or the cookie called s_v_web_id package got changed a few times up until now and may be working more consistently now

@viniciusao
Copy link

viniciusao commented Dec 5, 2020

I don't know how to get it in python. But when I decode tiktok in web after confirming, I get an api like this: "https://www.tiktok.com/node/share/user/@your_tiktok_username?verifyFp=verify_khwsg04i_Kjx9V5Ev_u6d2_4UiG_8p2n_LAsK5DB"

you could instantiate TikTokApi object with the custom_verifyFp='yourcookievalue'
api = TikTokApi(custom_verifyFp='yourcookievalue')

@rtheodoro
Copy link

@viniciusao do you know how to make it work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants