<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>Threads &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/threads/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Wed, 06 Nov 2024 12:15:01 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>Threads &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[A simple and free way to post RSS feeds to Threads]]></title>
		<link>https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/</link>
					<comments>https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Wed, 06 Nov 2024 12:30:00 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[Threads]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=53776</guid>

					<description><![CDATA[Threads is Meta&#039;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&#039;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. …]]></description>
										<content:encoded><![CDATA[<p><a href="https://threads.net">Threads</a> 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.</p>

<p>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.</p>

<p>You can see the bot in action at <a href="https://www.threads.net/@openbenches_org">https://www.threads.net/@openbenches_org</a></p>

<h2 id="get-the-code"><a href="https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/#get-the-code">Get the code</a></h2>

<p>The <a href="https://codeberg.org/edent/RSS2Threads">code is available as Open Source</a>. It should be fairly self explanatory for a moderately competent programmer - but feel free to open an issue if you think it is confusing.</p>

<h2 id="get-it-working"><a href="https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/#get-it-working">Get it working</a></h2>

<ol>
<li>Create an account on Threads (duh!) - this involves signing up to Instagram.</li>
<li>Create a Facebook Developer account.</li>
<li>Create <a href="https://developers.facebook.com/apps/">an app which requests the Threads posting API</a>.

<ul>
<li>You do not need to publish this app if you're only using it yourself.</li>
</ul></li>
<li>Create a User Token using the "User Token Generator"</li>
<li>Get your <a href="https://developers.facebook.com/docs/threads/threads-profiles/">Threads account's User ID</a> with:

<ul>
<li><code>curl -s -X GET "https://graph.threads.net/v1.0/me?ields=id,username,name,threads_profile_picture_url,threads_biography&amp;access_token=TOKEN"</code></li>
<li>(Yes, <code>ields</code>. If you use <code>fields</code> you get something else!)</li>
</ul></li>
<li>Clone the <a href="https://codeberg.org/edent/RSS2Threads">RSS2Threads repo</a> and stick it on a webserver somewhere.</li>
<li>Rename <code>config.sample.php</code> to <code>config.php</code> and add your feeds' details, along with your ID and Token.</li>
<li>Run <code>php rss2threads.php</code></li>
</ol>

<p>And that's it!</p>

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

<h2 id="how-i-built-it"><a href="https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/#how-i-built-it">How I built it</a></h2>

<p>Shoulders of giants, and all that! I have been using <a href="https://codeberg.org/nesges/rss2bsky">Thomas Nesges's RSS2BSky</a> for auto-posting to BlueSky. I also used <a href="https://github.com/0xjessel/threads-bart-bot">Jesse Chen's Python Threads example code</a>.</p>

<p>Posting is a two stage process.</p>

<ol>
<li>POST the URl encoded text to:

<ul>
<li><code>https://graph.threads.net/USER_ID/threads?text=My%20post&amp;access_token=TOKEN&amp;media_type=TEXT</code></li>
<li>If successful, the API will return a Creation ID.</li>
</ul></li>
<li>POST the Creation ID to:

<ul>
<li><code>https://graph.threads.net/USER_ID/threads_publish?creation_id=CREATION_ID&amp;access_token=TOKEN</code></li>
<li>If successful, the API will return a Post ID.</li>
</ul></li>
</ol>

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

<h2 id="caveats"><a href="https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/#caveats">Caveats</a></h2>

<ul>
<li>There are no unit tests, fuzzing, or exception handling. It's assumed you're running this on well-formed RSS that you trust.</li>
<li>The Threads API is <strong>slow!</strong> It takes ages for a post to be sent to it.</li>
<li><a href="https://developers.facebook.com/docs/development/create-an-app/threads-use-case">Getting a Threads API token</a> is <strong>difficult</strong> and the margin is too small for me to explain it here.</li>
</ul>

<h2 id="feedback"><a href="https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/#feedback">Feedback</a></h2>

<p>Please leave a comment here or <a href="https://codeberg.org/edent/RSS2Threads">on the code repository</a>.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=53776&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2024/11/a-simple-and-free-way-to-post-rss-feeds-to-threads/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
