junhoyeo / threads-api

Unofficial, Reverse-Engineered Node.js/TypeScript client for Meta's Threads. Web UI Included.
https://threads.junho.io
MIT License
1.58k stars 134 forks source link

How to `add` when creating a thread? (Fetching `PostID` Impossible) #149

Closed cedriking closed 11 months ago

cedriking commented 11 months ago

Hi everyone, amazing work and progress on the threads-api. I was wondering how can we post multiple threads one under the other? I was thinking it would be as simple as getting the post ID of the last published thread and keep going that way, but as soon as the first thread is published, I get this error:

data: { message: 'Unknown Server Error.', status: 'fail' }

I even tried to pause for 10 secs and it's still not working 🤔

The code I was trying is simple:

let parentPostID
for (const thread of data) {
  parentPostID = await threadsAPI.publish({
    text: thread.text,
    image: thread.image,
    parentPostID,
  })
  await sleep(10000)

  console.log(`Posted thread ${parentPostID}`)
}

Thanks for your help.

kevinfosse commented 11 months ago

Perhaps one solution would be to post a first thread, then retrieve the last thread posted and comment on it with the rest?

cedriking commented 11 months ago

I tried that already. After the sleep of 10secs I had

await threadsAPI.getUserProfileThreads(userID)

But it always return an empty array [] even that I have many posts created.

Also tried the following in case the returned string from publish() is a threadID and not a postID, but that returns undefined:

parentPostID = await threadsAPI.getPostIDfromThreadID(parentPostID)

So far the only thing that returns something that makes sense is publish() but that doesn't work when trying to be used as the parentPostID.

junhoyeo commented 11 months ago

image https://www.threads.net/t/CuqbBI8h19H

Looks like the webpage that getPostIDfromThreadID(getPostIDfromThreadURL) uses to fetch postID is dead 🤔

junhoyeo commented 11 months ago

Update: Think implementing https://github.com/junhoyeo/threads-py/pull/27 here too could be a fix.

cedriking commented 11 months ago

Seems it's back @junhoyeo 🙌🏼 that link is working https://www.threads.net/t/CuqbBI8h19H -> https://www.threads.net/@_junhoyeo/post/CuqbBI8h19H

I'm not able to post (not even single ones) now though 😰

cedriking commented 11 months ago

Thank you so much @junhoyeo for fixing this one. Waiting for the patch release 🙌🏼

junhoyeo commented 11 months ago

@cedriking Sorry I was late, just deployed https://github.com/junhoyeo/threads-api/releases/tag/v1.4.4!

aleclarson commented 11 months ago

I'm also getting Unknown Server Error when trying to post a reply to a post I just created (tested with v1.4.4).

cedriking commented 11 months ago

Same here, seems the issue is still active:

data: { message: 'Unknown Server Error.', status: 'fail' }