avilash/TikTokAPI-Python

ERROR - error in json decoder when I try to run the sample code

benostarzec opened this issue · 1 comments

When I try running this given sample code:
api = TikTokAPI(cookie=cookie)
retval = api.getTrending(count=5)

It throws this error:
Traceback (most recent call last):
File "/Users/benstarzec/Desktop/experiment/TikTokAPI_Python/avilash.py", line 11, in <module> retval = api.getTrending(count=5)
File "/Users/benstarzec/Desktop/experiment/TikTokAPI_Python/TikTokAPI/tiktokapi.py", line 104, in getTrending return self.send_get_request(url, params)
File "/Users/benstarzec/Desktop/experiment/TikTokAPI_Python/TikTokAPI/tiktokapi.py", line 84, in send_get_request data = get_req_json(url, params=None, headers=self.headers)
File "/Users/benstarzec/Desktop/experiment/TikTokAPI_Python/TikTokAPI/utils.py", line 29, in get_req_json return json.loads(r.text)
File "/Users/benstarzec/.conda/envs/DataAnalysis/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s)
File "/Users/benstarzec/.conda/envs/DataAnalysis/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/benstarzec/.conda/envs/DataAnalysis/lib/python3.7/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)

Not sure if this is a problem with the module as is or more likely I screwed something up installing it, but wondering if anyone has any insights. Thanks!

So, after like an hour of trying to fix this I solved my issue like a minute after posting this. My cookies were screwed up, so by not passing set cookies and using the default, I was able to use it as expected.