<?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>
	<copyright>© Terence Eden. 🄯 CC BY-SA. See https://shkspr.mobi/blog/copyright-and-copyleft/</copyright>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</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[Terence Eden]]></dc:creator>
		<pubDate>Wed, 06 Nov 2024 12:30:00 +0000</pubDate>
		<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>&lt;p&gt;&lt;a href="https://threads.net"&gt;Threads&lt;/a&gt; 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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;You can see the bot in action at &lt;a href="https://www.threads.net/@openbenches_org"&gt;https://www.threads.net/@openbenches_org&lt;/a&gt;&lt;/p&gt;

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

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

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

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

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

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

&lt;p&gt;And that's it!&lt;/p&gt;

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

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

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

&lt;p&gt;Posting is a two stage process.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;POST the URl encoded text to:

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

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

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

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

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

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

&lt;p&gt;Please leave a comment here or &lt;a href="https://codeberg.org/edent/RSS2Threads"&gt;on the code repository&lt;/a&gt;.&lt;/p&gt;
&lt;img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=53776&amp;amp;HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager"&gt;</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>
