<?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>Worth Retweeting &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/2009/05/worth-retweeting/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Wed, 04 Oct 2023 15:42:05 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>Worth Retweeting &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Worth Retweeting]]></title>
		<link>https://shkspr.mobi/blog/2009/05/worth-retweeting/</link>
					<comments>https://shkspr.mobi/blog/2009/05/worth-retweeting/#respond</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Tue, 05 May 2009 10:50:00 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/index.php/2009/05/worth-retweeting/</guid>

					<description><![CDATA[Recently, I&#039;ve seen a lot of people retweeting content that I&#039;ve already seen.&#34;How very annoying,&#34; I thought to myself, &#34;I wish someone would do something about that.&#34;So, like any self-respecting geek, I rolled up my sleeves and got on with it :-)My PHP is a little rusty, but luckily the twitter API is fairly easy.My first pass was an abject lesson of inefficiency and illiteracy.  Here was my…]]></description>
										<content:encoded><![CDATA[<p>Recently, I've seen a lot of people retweeting content that I've already seen.<br>"How very annoying," I thought to myself, "I wish someone would do something about that."<br><br>So, like any self-respecting geek, I rolled up my sleeves and got on with it :-)<br><br>My PHP is a little rusty, but luckily the twitter API is fairly easy.<br><br>My first pass was an abject lesson of inefficiency and illiteracy.  Here was my thought process...<br></p>

<ol><li>Get the ID of the person I want to retweet<br></li><li>Get all of My Followers</li><li>Get the people that my followers follow</li><li>See how many of them follow the person I want to retweet.</li></ol>

<p>This <span style="font-style: italic;">did</span> work but it was horribly slow.  Also, the twitter API is limited to 100 requests per hour.  If you have over 100 followers, you won't get anywhere.<br><br>However, on closer reading of the API - and a little tiramisu - I had the answer.<br></p>

<ol><li>Get my followers</li><li>Get the retweetee's followers</li><li>See how many from (1) occur in  (2)</li></ol>

<p>This can be accomplished in a few lines of PHP.<br><br>To get the first 5,000 followers for any user - use this URL<br></p>

<blockquote>$myfollowers_url = "http://twitter.com/followers/ids.json?screen_name=" . $my_name . "&amp;page;=1";</blockquote>

<p>Then use curl to grab the data -<br></p>

<blockquote>$curl_handle=curl_init();curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);<br>curl_setopt($curl_handle,CURLOPT_URL,$myfollowers_url);<br>$myfollowers_json = curl_exec($curl_handle);<br>curl_close($curl_handle);</blockquote>

<p>You can turn the resulting JSON into an array thus:<br></p>

<blockquote>$myfollowers_array = explode("," , $myfollowers_string);</blockquote>

<p>You do the same for the person you wish to retweet.<br>PHP provides the method <span style="font-style: italic;">array_intersect()</span> to see how many elements from array1 occur in array2.<br></p>

<blockquote>$samefollowers_count = count(array_intersect($myfollowers_array,$theirfollowers_array));</blockquote>

<p><br>From there, the maths is trivial.<br></p>

<blockquote>$myfollowers_count = count($myfollowers_array);<br>$theirfollowers_count = count($theirfollowers_array);<br>$ratio = $samefollowers_count / $myfollowers_count;</blockquote>

<p><br>Hey presto! Done.  You can view the beta at <a href="https://web.archive.org/web/20090509222740/https://shkspr.mobi/twitter/retweet.php">https://shkspr.mobi/twitter/retweet.php</a></p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=17&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2009/05/worth-retweeting/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
