A simple and free way to post RSS feeds to Threads


Threads is Meta's attempt to disrupt the social media landscape. Whether you care for it or not, there are a lot of users there. And, sometimes, you have to go where the audience is.

Here's how I build a really simple PHP tool to post to Threads using their official API. This allows you to send a single status update programatically, or regularly send new items from your RSS feed to an account.

You can see the bot in action at https://www.threads.net/@openbenches_org

Get the code

The code is available as Open Source. It should be fairly self explanatory for a moderately competent programmer - but feel free to open an issue if you think it is confusing.

Get it working

  1. Create an account on Threads (duh!) - this involves signing up to Instagram.
  2. Create a Facebook Developer account.
  3. Create an app which requests the Threads posting API.
    • You do not need to publish this app if you're only using it yourself.
  4. Create a User Token using the "User Token Generator"
  5. Get your Threads account's User ID with:
    • curl -s -X GET "https://graph.threads.net/v1.0/me?ields=id,username,name,threads_profile_picture_url,threads_biography&access_token=TOKEN"
    • (Yes, ields. If you use fields you get something else!)
  6. Clone the RSS2Threads repo and stick it on a webserver somewhere.
  7. Rename config.sample.php to config.php and add your feeds' details, along with your ID and Token.
  8. Run php rss2threads.php

And that's it!

The service will download your RSS feed, check if it has posted the entries to Threads and, if not, post them.

How I built it

Shoulders of giants, and all that! I have been using Thomas Nesges's RSS2BSky for auto-posting to BlueSky. I also used Jesse Chen's Python Threads example code.

Posting is a two stage process.

  1. POST the URl encoded text to:
    • https://graph.threads.net/USER_ID/threads?text=My%20post&access_token=TOKEN&media_type=TEXT
    • If successful, the API will return a Creation ID.
  2. POST the Creation ID to:
    • https://graph.threads.net/USER_ID/threads_publish?creation_id=CREATION_ID&access_token=TOKEN
    • If successful, the API will return a Post ID.

Successful RSS posts are stored in a simple SQLite database. If an RSS entry was posted successfully, it won't be reposted.

Caveats

  • There are no unit tests, fuzzing, or exception handling. It's assumed you're running this on well-formed RSS that you trust.
  • The Threads API is slow! It takes ages for a post to be sent to it.
  • Getting a Threads API token is difficult and the margin is too small for me to explain it here.

Feedback

Please leave a comment here or on the code repository.


Share this post on…

  • Mastodon
  • Facebook
  • LinkedIn
  • BlueSky
  • Threads
  • Reddit
  • HackerNews
  • Lobsters
  • WhatsApp
  • Telegram

One thought on “A simple and free way to post RSS feeds to Threads”

Trackbacks and Pingbacks

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">