GithubHelp home page GithubHelp logo

danie1 / threads-api Goto Github PK

View Code? Open in Web Editor NEW
110.0 110.0 15.0 199 KB

Unofficial Python API for Meta's Threads App

Home Page: https://pypi.org/project/threads-api/

License: MIT License

Python 100.00%
instagram instagram-api meta opensource python socialmedia threads threads-api

threads-api's People

Contributors

danie1 avatar fernandaochoa avatar pj8912 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

threads-api's Issues

Login complains PIL is not installed in 1.1.3

Tried to run the example to create a post using the latest 1.1.3 version and the script complains PIL is not installed even though it is...

raise Exception("You don't have PIL installed. Please install PIL or Pillow>=8.1.1") Exception: You don't have PIL installed. Please install PIL or Pillow>=8.1.1

Post along with open graph preview?

This is working great, thank you for your hard work!

When I post a URL is there a way to make it pull in the open graph preview like it does when you type it into the editor?

Or is the correct approach to post the text and the url with an attachment for the image instead?

bug get_user_threads

function get_user_threads is same function as get_user_replies because 'doc_id' is the same, u need to change doc_id to 6232751443445612

Issue with post creation

Hello,
whenever I try to post a new Thread I'm getting this error right after message:
INFO:Set logged-in state successfully. All set!

DEBUG:Starting new HTTPS connection (1): i.instagram.com:443
DEBUG:https://i.instagram.com:443 "POST /api/v1/media/configure_text_only_post/ HTTP/1.1" 404 21807
[ERROR]  Failed to decode response as JSON
Traceback (most recent call last):
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.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/sites/26a/0/09b25bf6df/public_html/reqs.py", line 26, in post
    resp = response.json()
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.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/sites/26a/0/09b25bf6df/public_html/test.py", line 27, in <module>
    loop.run_until_complete(main())
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/sites/26a/0/09b25bf6df/public_html/test.py", line 23, in main
    await post()
  File "/home/sites/26a/0/09b25bf6df/public_html/test.py", line 13, in post
    result = await api.post("Hello world!")
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
    return await func(self, *args, **kwargs)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 1079, in post
    res = await self._private_post(url=post_url, headers=headers,data=payload)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
    return await func(self, *args, **kwargs)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 157, in _private_post
    return await self._auth_session.post(**kwargs)
  File "/home/sites/26a/0/09b25bf6df/public_html/reqs.py", line 32, in post
    raise Exception('Failed to decode response as JSON')
Exception: Failed to decode response as JSON

Does anyone know what should this one mean? Thanks

AioHTTPSession.get() takes 1 positional argument but 2 were given

Hi,

Trying for the first time the packages. Python 3.9
I have installed the requirements.

site-packages\threads_api\src\threads_api.py", line 997, in __download
async with self._auth_session.get(url) as response:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AioHTTPSession.get() takes 1 positional argument but 2 were given
ERROR:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001D432D9BF10>

Issue occured because I wrote image_path="logo.jpg" instead of image_path="logo.png". So here error must be caught properly... Upgrade needed :)

Post API no longer working, "ChallengeChoice.EMAIL" and "You've Been Logged Out"

Since today morning I can't post using this API anymore. It requests an email challenge, but after I enter the required code it raises this error:

[ERROR]  Request Failed, got back: [{'message': 'login_required', 'error_title': "You've Been Logged Out", 'error_body': 'Please log back in.', 'logout_reason': 8, 'status': 'fail'}]

Also, sometimes it's triggering a security alert on instagram/threads.net, and I need to change the password (already changed it sometimes but still not working).

Update: sometimes it raises this error instead:

Exception: Request Failed, got back: [{'message': 'Please wait a few minutes before you try again.', 'status': 'fail'}]

post threads

Hello! Can you please let me know if you will be able to post soon?

how to work

hello i am new at using this api and i would like to have examples of how to scrap threads of an account using username either by post count or period of dates (since until) thanks

instagram blocked my IP

After the fourth run of the get_user_id_from_username method, the script throws the following exception: instagram.exceptions.ProxyAddressIsBlocked: Instagram has blocked your IP address, use a quality proxy provider (not free, not shared)
is there any support for authorization by sessions?

try video uploading

I tried video uploading with reference to "instagrapi."

Error when not uploading thumbnail.
{"message":"media_needs_reupload","media":{"upload_id":1,"device_timestamp":"1"},"error_title":"cover_photo_upload_error","status":"ok"}

I tried to upload a thumbnail, I got an error.
{"debug_info":{"retriable":false,"type":"ProcessingFailedError","message":"Request processing failed"}}

I'm attaching the source so far because I don't know what it is.
If you don't want it, please close it.

threads_api.zip

image(image_path = wrong url) upload bug

/opt/Threads/venv/lib/python3.9/site-packages/threads_api/src/threads_api.py:1084: RuntimeWarning: coroutine 'ThreadsAPI.post.<locals>.__is_valid_url' was never awaited
  if not __is_valid_url(image_path):
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

may be
if not await __is_valid_url(image_path):

Multiple post replies on the same thread?

I am currently trying to replicate a bot I saw on Twitter which has the following functionality:

// Reddit GET request to get the weeks top 5 posts in r/worldnews
response = requests.get(f"https://www.reddit.com/r/worldnews/top.json?sort=top&t=week", headers={"User-Agent": "Mozilla/5.0"})

// Extract the top 5 threads from the response
threads = response.json()["data"]["children"][:5]

// Create tweet message with the first post and thread posts
tweet_msg = "Headlines for the week:"
first_thread = threads[0]
first_title = first_thread["data"]["title"]
first_url = first_thread["data"]["url"]
tweet_msg += f"No. 1: {first_title}\n{first_url}\n\n"

// Post the first tweet
first_tweet = api.update_status(tweet_msg)
print("First tweet posted successfully!")

// Reply to the first tweet with the thread posts
for i, thread in enumerate(threads[1:], 2):
title = thread["data"]["title"]
url = thread["data"]["url"]
reply_msg = f"No. {i}: {title}\n{url}\n\n"
api.update_status(reply_msg, in_reply_to_status_id=first_tweet.id)
print(f"Thread {i} posted successfully!")

print("All threads posted successfully!")

I am trying to find the command in the documentation to action the final step of self replying to the first tweet with the thread posts but I am unable to get any leads. Is this possible in the current state or is it a feature that needs to be implemented?
Thanks for the pointers!

why always logged out?

threads_api.src.threads_api.LoggedOutException: {'message': 'login_required', 'error_title': "You've Been Logged Out", 'error_body': 'Please log back in.', 'logout_reason': 8, 'status': 'fail'}

Uploading post with image doesn't work anymore since today

Uploading posts with image worked fine for a few days (even though Instagram/Threads complained via email every time about my bot being hosted in a different country, and I checked in the security setting that it's fine that way).

I've tried all three HTTP session classes in the threads-api, it makes no difference. Threads returns an error, and an HTML page twice, displaying "this page does not exist".

Full error log incl. HTML is attached below.

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 "/app/.heroku/python/lib/python3.11/site-packages/threads_api/src/threads_api.py", line 168, in _extract_response_json
    resp = json.loads(response)
           ^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/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 "/app/bot.py", line 164, in <module>
    asyncio.run(main())
  File "/app/.heroku/python/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/app/bot.py", line 159, in main
    await post_include_image(api) # Posts a message with an image.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/bot.py", line 138, in post_include_image
    result = await api.post("#bot", image_path=download_img)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/threads_api/src/threads_api.py", line 1131, in post
    res = await self._private_post(url=post_url, headers=headers,data=payload)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/threads_api/src/threads_api.py", line 181, in _private_post
    resp_json = self._extract_response_json(response)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/threads_api/src/threads_api.py", line 173, in _extract_response_json
    raise Exception(f'Failed to decode response [{response}] as JSON.\n\n{OPEN_ISSUE_MESSAGE}')
Exception: Failed to decode response [<!DOCTYPE html>

threads-api-error.txt

ERROR:Unclosed client session

It posts the thread but I think there is an issue in creating the session to avoid future logins.

Post has been successfully posted ERROR:Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0000014F7491D130> ERROR:Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x0000014F749E2160>, 245380.64)]'] connector: <aiohttp.connector.TCPConnector object at 0x0000014F7491D190>

My code:

from threads_api.src.http_sessions.aiohttp_session import AioHTTPSession
import asyncio
import os
from dotenv import load_dotenv


load_dotenv()


async def post():
    threads_api = ThreadsAPI()
    await threads_api.login('username', 'password')
    result = await threads_api.post("I am posting this from the threads api!")

    if result:
        print("Post has been successfully posted")
    else:
        print("Unable to post.")

async def main():
    await post()

# Create an event loop and run the main function
loop = asyncio.get_event_loop()
loop.run_until_complete(main())```

Error with the login response

await api.login(username=username, password=password, cached_token_path=".token")

why it mades error
[ERROR] Error with the login response

Request Failed

Response code 404 - System Error
Request Failed, got back: [{'message': 'login_required', 'error_title': "You've Been Logged Out", 'error_body': 'Please log back in.', 'logout_reason': 8, 'status': 'fail'}]
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.

It worked few time, so now i am getting error every time I try to run a script.

Login Issues

I went ahead and looked at the data being returned by Threads. I'm getting the following JSON with a known good username/password. I replaced anything that looks like sensitive data and presented the json in pretty printed format (removing the escapes as well).

{
  "layout": {
    "bloks_payload": {
      "data": [],
      "props": [
        {
          "id": "<KEPT SECRET>",
          "name": "ttrc_instance_id"
        },
        {
          "id": "<KEPT SECRET>",
          "name": "override_login_success_action"
        }
      ],
      "error_attribution": {
        "logging_id": "{\"callsite\":\"{\\\"product\\\":\\\"bloks_caa_login\\\",\\\"feature\\\":\\\"com.bloks.www.bloks.caa.login.async.send_login_request\\\",\\\"integration\\\":\\\"bloks_screen\\\",\\\"oncall\\\":\\\"caa_login\\\"}\",\"push_phase\":\"C3e\",\"version\":1,\"request_id\":\"<KEPT SECRET>\"}"
      },
      "tree": {
        "㐟": {
          "#": " (bk.action.core.TakeLast,
             (ig.action.cdsdialog.OpenDialog,
             (bk.action.tree.Make,
             (bk.action.i32.Const,
             13799),
             (bk.action.i32.Const,
             40),
             "Unable to log in",
             (bk.action.i32.Const,
             35),
             "An unexpected error occurred. Please try logging in again.",
             (bk.action.i32.Const,
             36),
             (bk.action.tree.Make,
             (bk.action.i32.Const,
             13800),
             (bk.action.i32.Const,
             36),
             "OK",
             (bk.action.i32.Const,
             35),
             (bk.action.core.FuncConst,
             (bk.action.logging.LogEvent,
             "caa_login_client_events_ig",
             "",
             (bk.action.map.Make,
             (bk.action.array.Make,
             "core",
             "login_params"),
             (bk.action.array.Make,
             (bk.action.map.Make,
             (bk.action.array.Make,
             "event",
             "event_category",
             "event_flow",
             "event_request_id",
             "event_step",
             "is_dark_mode",
             "exception_code",
             "exception_message",
             "exception_type",
             "extra_client_data",
             "logged_out_identifier",
             "logged_in_identifier",
             "waterfall_id"),
             (bk.action.array.Make,
             "login_error_dialog_ok_clicked",
             "login_home_page_interaction",
             "login_manual",
             "<KEPT SECRET>",
             "home_page",
             (ig.action.IsDarkModeEnabled),
             (bk.action.i32.Const,
             0),
             "",
             "",
             (bk.action.map.Make,
             (bk.action.array.Make),
             (bk.action.array.Make)),
             "",
             "",
             "<KEPT SECRET>")),
             (bk.action.map.Make,
             (bk.action.array.Make),
             (bk.action.array.Make))))))),
             (bk.action.i32.Const,
             42),
             (bk.action.i32.Const,
             0)),
             (bk.action.tree.Make,
             (bk.action.i32.Const,
             13808))),
             (bk.action.map.Make,
             (bk.action.array.Make,
             "should_dismiss_loading"),
             (bk.action.array.Make,
             (bk.action.bool.Const,
             true))))"
        }
      }
    }
  },
  "status": "ok"
}

The error given by the module is:

Exception: Error with the login response

The code generating this is simply:

from threads_api.src.threads_api import ThreadsAPI
import asyncio, os

myUsername = 'myUsername'
myPassword = 'myPassword'

async def post():
	api = ThreadsAPI()
	await api.login(myUsername, myPassword, cached_token_path=".token")
	result = await api.post("testing")

	if result:
		print("Post has been successfully posted")
	else:
		print("Unable to post.")

async def main():
	await post()

# Create an event loop and run the main function
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

get post id from url except

/Users/a123/PycharmProjects/pythonProject/venv2/bin/python /Users/a123/PycharmProjects/pythonProject/thre/test.py
/Users/a123/PycharmProjects/pythonProject/thre/test.py:19: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
Traceback (most recent call last):
File "/Users/a123/PycharmProjects/pythonProject/thre/test.py", line 20, in
loop.run_until_complete(main())
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/a123/PycharmProjects/pythonProject/thre/test.py", line 16, in main
await get_post_id_from_url()
File "/Users/a123/PycharmProjects/pythonProject/thre/test.py", line 12, in get_post_id_from_url
post_id = await threads_api.get_post_id_from_url(post_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/a123/PycharmProjects/pythonProject/venv2/lib/python3.11/site-packages/threads_api/src/threads_api.py", line 344, in get_post_id_from_url
return post_id.group(1)
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'

.get_user_id_from_username() returns None for valid usernames

It worked yesterday, but something happened between now and then to make it stop working.

I used zuck as the username, but when I did threads_api.get_user_id_from_username('zuck'), it returned None instead of a valid username.

Is this something wrong in my code or a bug?

authentification failed

hello there. i can't login to api via my insta login and password.
"Username or password are invalid".
I don't have another logins to threads

is login and pass to Threads different?

[BUG] login InstagrapiSession

Some bug when handling login response with InstagrapiSession.
[ERROR] list index out of range
Traceback (most recent call last):
File "D:\user\prog\threads_bot\v2\main.py", line 22, in
asyncio.run(main())
File "C:\Users\Bou\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\Bou\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Bou\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\user\prog\threads_bot\v2\main.py", line 18, in main
await bot.start()
File "D:\user\prog\threads_bot\v2\threads_manager\timeline_manager.py", line 34, in start
await self.login(self.username, self.password, cached_token_path="data\.session")
File "D:\user\prog\threads_bot\v2\venv\Lib\site-packages\threads_api\src\threads_api.py", line 257, in login
token = self.instagrapi_client.private.headers['Authorization'].split("Bearer IGT:2:")[1]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Process finished with exit code 1

Like don't work

Seems as api was changed.
Traceback (most recent call last):
File "D:\user\prog\threads_bot\v2\tests\test.py", line 21, in
loop.run_until_complete(main())
File "C:\Users\Bou\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\user\prog\threads_bot\v2\tests\test.py", line 17, in main
await post()
File "D:\user\prog\threads_bot\v2\tests\test.py", line 9, in post
result = await api.like_post("1")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\user\prog\threads_bot\v2\venv\Lib\site-packages\threads_api\src\threads_api.py", line 501, in like_post
return res["status"] == "ok"
~~~^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable


from threads_api.src.threads_api import ThreadsAPI
import asyncio
import os


async def post():
    api = ThreadsAPI()
    await api.login("user", "pass", cached_token_path="..\\data\\.session")
    result = await api.like_post("1")
    print(result)
    if result:
        print("Post has been successfully posted")
    else:
        print("Unable to post.")

async def main():
    await post()

# Create an event loop and run the main function
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

By hands, on phone, liking works.

Cant use on web server

I've created a flask web app that works locally but when I go to deploy it on glitch or pythonanywhere when I try and pull the info (ie use a search box to find a users info) it doesn't return anything and I can't see any issues as to why error wise. Do you have any suggestions on how to resolve?

How did you reverse?

Hi, reversing the web version is of course no problem, but how to reverse the Threads application, I can't figure out. I used httptoolkit, which could not decode the https traffic. I also used fiddler, which did not show the requests normally. So I would be very grateful if you could explain how you were able to sniff the traffic, or maybe link to the tutorial you did.

api.post function from example.py gives me the following error

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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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>

help

raise Exception("Error with the login response")

Exception: Error with the login response

It give a noneType error running public_api_examples

I ran example.py and got lots errors;

asyncio.run(get_user_id_from_username()) # Retrieves the user ID for a given username.
#asyncio.run(get_user_profile()) # Retrieves the threads associated with a user.
#asyncio.run(get_user_threads()) # Retrieves the replies made by a user.
asyncio.run(get_user_replies()) # Retrieves the profile information of a user.
#asyncio.run(get_post_id_from_url()) # Retrieves the post ID from a given URL.
#asyncio.run(get_post()) # Retrieves a post and its associated replies.
#asyncio.run(get_post_likes()) # Retrieves the likes for a post.

So I tried examples/publi* and I got this error.
I JUST installed it 3 hours ago and have been stumbling around.

user@Annas-MacBook-Pro-2 examples % DEBUG=DEBUG python3 ./public_api_examples.py
Executing API calls using [<class 'threads_api.src.http_sessions.aiohttp_session.AioHTTPSession'>] session.
The replies for user 'sevenonsix' are:
-
dave_it_up's Post: There is a legume though. 😜 || Likes: 0
sevenonsix's Reply: Ok ok ok.... I forgot..

My squirrels THINK it is a nut!!! || Likes: 1
-
-
pamela.roza.hayes's Post: Does anybody else's 'Following' tab look like this? I know I'm following people... || Likes: 0
sevenonsix's Reply: Maybe log out then back in??? || Likes: 0
-
-
kbarkerb's Post: πŸ’™πŸ‡ΊπŸ‡ΈπŸ’™πŸ‡ΊπŸ‡ΈπŸ’™πŸ‡ΊπŸ‡Έ || Likes: 72
sevenonsix's Reply: If I were to repeat this information,  is there specific detail? I'm sure it's true because I see congress people vote for and against on different votes of a bill.
I would hate to spread misinformation || Likes: 2
-
-
licia_haze's Post: So if TFG asks his followers to drink the poison, we can all assume they will? || Likes: 3
sevenonsix's Reply: Can we skip poison and simply have all get an serious to be happy friendly people? || Likes: 0
-
-
torilink65's Post: Me either, great as they all are. || Likes: 1
sevenonsix's Reply: 7500 people... I'm having difficulty remembering  1000!!! || Likes: 0
-
-
oscaroc1975's Post: https://www.axios.com/2023/08/17/nc-republicans-override-vetoes-controversial-bills-lgbtq-charter-schools

Not just FL || Likes: 1
sevenonsix's Reply: Why would anyone prestate their medical opinion when they don't know any circumstances or have medical, psychiatrists, or psychological knowledge?
It is just ignorant to feel you understand even a small portion of others experiences. || Likes: 1
-
-
janinedavisexecutivecoach's Post: Daily Dose of Nature

I needed that yesterday. β¬‡οΈπŸŒˆ. My soulmate puppy loved to eat skittles and whenever I see a rainbow it feels like he’s saying hello. || Likes: 23
sevenonsix's Reply: Private or deleted??? || Likes: 0
-
Traceback (most recent call last):
  File "/Users/user/Documents/GitHub/threads-api/examples/./public_api_examples.py", line 132, in <module>
    asyncio.run(main())
  File "/usr/local/Cellar/[email protected]/3.10.6_2/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/[email protected]/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/Users/user/Documents/GitHub/threads-api/examples/./public_api_examples.py", line 124, in main
    await get_user_replies(api) # Retrieves the profile information of a user.
  File "/Users/user/Documents/GitHub/threads-api/examples/./public_api_examples.py", line 46, in get_user_replies
    print(f"-\n{post.user.username}'s Post: {post.caption.text} || Likes: {post.like_count}")
AttributeError: 'NoneType' object has no attribute 'text'
ERROR:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111c842e0>
ERROR:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111c84640>
ERROR:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x111c3a3e0>, 15689.235792789)]', '[(<aiohttp.client_proto.ResponseHandler object at 0x111c3b940>, 15690.20503807)]']
connector: <aiohttp.connector.TCPConnector object at 0x111c84220>
user@Annas-MacBook-Pro-2 examples % 

ask

can get post from user specify?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.