Danie1 / threads-api

Unofficial Python API for Meta's Threads App
https://pypi.org/project/threads-api/
MIT License
121 stars 16 forks source link

It give a noneType error running public_api_examples #64

Open gddeen opened 1 year ago

gddeen commented 1 year ago

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/python@3.10/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/python@3.10/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 % 
gddeen commented 1 year ago

I was looking to go through and build a list of people I follow. Then I was going to go through that list a week later and unfollow them if they didn't follow me.

And play around with the API a bunch...

gddeen commented 1 year ago

I added if statements before all the places I get NoneType which is about 4 objects...