Sorry, this page isn't available.
The link you followed may be broken, or the page may have been removed. Go back to Instagram.
Open kouroshshafi opened 1 year ago
Hey, please run the script with the environment variable LOG_LEVEL
set to DEBUG
. It will print the request+responses, and it sometimes hints on the issue.
I am speculating the login did not really succeed, despite the message.
I will gladly assist once you have the additional details.
Please re-open with additional info if still reproduces after version v1.1.13 (https://github.com/Danie1/threads-api/releases/tag/v1.1.13). It contains improvements in this area, so at the very least it will be easier to troubleshoot.
Here is the error I get
[ERROR] Failed to decode response [<!DOCTYPE html>
The link you followed may be broken, or the page may have been removed. Go back to Instagram.
] as JSON.
Oops, this is an error that hasn't yet been properly handled.
Please open an issue on Github at https://github.com/Danie1/threads-api.
Traceback (most recent call last):
File "/Users/kouroshshafi/Desktop/threads-api-1.1.13/threads_api/src/threads_api.py", line 168, in _extract_response_json
resp = json.loads(response)
File "/opt/anaconda3/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/opt/anaconda3/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/anaconda3/lib/python3.9/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)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
The link you followed may be broken, or the page may have been removed. Go back to Instagram.
] as JSON.
Oops, this is an error that hasn't yet been properly handled. Please open an issue on Github at https://github.com/Danie1/threads-api.
Hey @kouroshshafi, please include the REQUEST and RESPONSE headers, like so once you run with the LOG_LEVEL=DEBUG" environment variable:
<---- START ---->
Keyword arguments:
[title]: ["PUBLIC REQUEST"]
[type]: ["GET"]
[url]: ["https://www.instagram.com/instagram"]
[headers]: [{
"Authority": "www.threads.net",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9",
"Cache-Control": "no-cache",
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "https://www.threads.net",
"Pragma": "no-cache",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15",
"X-ASBD-ID": "129477",
"X-IG-App-ID": "238260118697367"
}]
<---- END ---->
Login status: Success [ERROR] Failed to decode response as JSON Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/threads_api/src/http_sessions/aiohttp_session.py", line 36, in post resp = json.loads(text) File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/kouroshshafi/Desktop/twitter-threads-kourosh/twitter-threads.py", line 214, in
asyncio.run(post()) # Posts a message.
File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/Users/kouroshshafi/Desktop/twitter-threads-kourosh/twitter-threads.py", line 144, in post
result = await api.post("Hello World API test!")
File "/usr/local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
return await func(self, *args, *kwargs)
File "/usr/local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 1105, in post
res = await self._private_post(url=post_url, headers=headers,data=payload)
File "/usr/local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
return await func(self, args, kwargs)
File "/usr/local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 166, in _private_post
return await self._auth_session.post(kwargs)
File "/usr/local/lib/python3.10/site-packages/threads_api/src/http_sessions/aiohttp_session.py", line 42, in post
raise Exception('Failed to decode response as JSON')
Exception: Failed to decode response as JSON
ERROR:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x12549f100>
ERROR:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x1254afb20>, 69683.022677739)]']
connector: <aiohttp.connector.TCPConnector object at 0x12549f070>