Danie1 / threads-api

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

Post along with open graph preview? #33

Closed omiq closed 11 months ago

omiq commented 12 months ago

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?

Danie1 commented 12 months ago

Thank you, and thanks for choosing threads-api :)

Will you be able to refine what you mean? Can you show an example by any chance?

omiq commented 12 months ago

This is the thread posted using my script

Screenshot by Dropbox Capture

This was posted using the app

Screenshot by Dropbox Capture

Danie1 commented 11 months ago

Hey @omiq , did you find a solution to get this working for you? I would like to address this.

omiq commented 11 months ago

No but when you enter the URL into the app there seems to be a small delay before it loads the preview, so I wonder if it is a timing thing?

Danie1 commented 11 months ago

It seems to have worked with the "threads.net" url just now, when it hasn't worked for me previously.

I removed any identifying information, and attached proof of it here: image

Did you try other URLs? Is it working for you today?

omiq commented 11 months ago

Unfortunately it doesn't work with my URL, which does work interactively. Maybe threads own domain is whitelisted?

    # Login using secrets
    await api.login(instagram_secret.instagram_user,instagram_secret.instagram_password, cached_token_path=".token")
    result = await api.post(caption="How to Write a Compelling Blog Post That Your Audience Will Be Glued to Right to the End\n\nhttps://www.chrisg.com/compelling-blog-content/\n\n")
omiq commented 11 months ago

I think the key to this is the slight delay when the UI notices the URL to embed, and might explain why using their own domain works because of the speed difference? IMG_2506

Danie1 commented 11 months ago

Unfortunately it doesn't work with my URL, which does work interactively. Maybe threads own domain is whitelisted?

    # Login using secrets
    await api.login(instagram_secret.instagram_user,instagram_secret.instagram_password, cached_token_path=".token")
    result = await api.post(caption="How to Write a Compelling Blog Post That Your Audience Will Be Glued to Right to the End\n\nhttps://www.chrisg.com/compelling-blog-content/\n\n")

I see you are calling the wrong API when posting with a URL. Please try like this: https://github.com/Danie1/threads-api/blob/ffd0e6afc07bbaded4394e4caedd12a1e9a81e7c/examples/private_api_examples.py#L83-L90

omiq commented 11 months ago

Ohhh I am so sorry, that worked! How embarrassing!