Voskhod instruments by Tom Royal on Flickr
Valentina Tereshkova with Vostok 6 by Tom Royal on Flickr
Voskhod Capsule by Tom Royal on Flickr
Chartwell by Tom Royal on Flickr
Chartwell by Tom Royal on Flickr
Heron by Tom Royal on Flickr
Highgate Cemetery by Tom Royal on Flickr
Highgate Cemetery by Tom Royal on Flickr
Highgate Cemetery by Tom Royal on Flickr
Highgate Cemetery by Tom Royal on Flickr

You're using a very old version of Internet Explorer which can't show the photos that should be in this box. Please consider upgrading to a newer version of IE or an alternative such as Firefox. Thanks.

How To: Write a RTing Twitter bot in PHP

January 19th, 2015

File this one under “stuff I’ve been meaning to look up for ages”: yesterday I finally sat down and wrote a Twitter-bot. You know the kind – a dedicated account that looks for updates containing a certain word or phrase, then retweets them – I often end up being tweeted by @redscarebot, for example.

Anyhow, here’s how to write your own, in just a few lines of PHP. You’ll need:

1) A server running PHP and MySQL (I set up an Appfog instance)

2) A Twitter account to post from, with a mobile phone number entered in settings

3) A computer somewhere to execute the script every X minutes via CRON

So, with all that in place: download and extra the TwitterOAuth library, then start a new PHP file. Require it:

require "twitteroauth/autoloader.php";
use Abraham\TwitterOAuth\TwitterOAuth;

Register an app at apps.twitter.com, then define the secrets required to access the API in your code:

define('CONSUMER_KEY', 'here');
define('CONSUMER_SECRET', 'here');
define('ACCESS_TOKEN', 'here');
define('ACCESS_TOKEN_SECRET', 'here');

Define your connection:


And then you’re ready to make a call to the Twitter API. You’ll probably want to search:

$sstring = '"sleepy cats" OR kittens';
$searchresult = $twitter->get("search/tweets", array("q" => urlencode($sstring), "since_id" => $since, "count" => 100, "result_type" => "recent"));

Note the variable $since – this is the ID of the last tweet processed by the bot on its last execution, used to prevent retweeting the same stuff over and over. Store and retrieve it from MySQL.

You know have $searchresult, and you’ll want to get the tweets out of it:

foreach($searchresult as $tweet) {
$tweettext = $tweet->text;
$tweetid = $tweet->id;

.. and you can do whatever you want with those. Want to post a message, probably created by trimming and formatting selected content from the search output? If you have your message in $somestatus

$postthis = $twitter->post("statuses/update", array("status" => $somestatus));

.. and that’s about it. Update your $since ID in MySQL, and close up the PHP file. Call it by CRON every X minutes to check for and retweet new messages.

This is only just barely scratching the surface, of course. Each tweet object contains loads of information that you can process to do more interesting things – see the API reference for details.

When bad news makes money, making up bad news is good business

September 5th, 2013

The other day a message scrolled past in my Twitter feed:


Which made me think: if the sea off Fukushima really were boiling, I’m pretty sure we would have heard about it. Except if there were some sort of amazing cover-up, in which case why would NHK (which is, essentially, the Japanese BBC) be showing pictures? Doesn’t make sense. But a quick search showed that the photo was being shared left, right and centre – everyone wanted to pass on the latest bad news. Some people even expanded the story to include an (also fake) evacuation order.

But where does a story like this come from? With some translation help from Morgan Giles, I was able to find the source of the photo: an NHK News report broadcast on 3/8/13. So that’s the photo, but somebody must have misinterpreted it.

Most links on Twitter came via an Energy News piece, “BBC website links to report claiming ocean is ‘boiling’ in front of Fukushima Daiichi (PHOTOS)” (see note 1 below), which in turn linked to a fairly hilariously inept article on the Voice of Russia. The Voice of Russia’s sole source is “a Twitter photo”, though (journalism!), so it’s not the root of the story.

Go further back a day, though, and you find an article published on The National Report: ‘BREAKING… Fukushima Crisis Escalates Tons of Radioactive Waste Released into the Pacific Causes Ocean to Boil…’, complete with that NHK screencap:


This does seem to be the genesis of the whole story. And, as noted above, the whole story is a lie. So why does it exist? A dig around the National Report website suggests fairly depressing motivation: if bad news makes money, making up bad news is good business.

Much of the website’s content is collegiate-level satire – The Onion this ain’t – but of late the editors have started to run a series of what appear to be intentionally shocking stories written just for the clicks. A few months ago, just after the Treyvon Martin verdict, it ran with the (false) news that George Zimmerman was to sue Martin’s parents:


.. while today it’s leading on some pretty nasty stuff designed to create immigration-related outrage (side note: anyone able to track down the guy in this photo? He’d have a lawsuit and a half..)


.. and as for Fukushima, the story proved so popular that it went back for another try. This time, a reporter was dispatched to the “village of Fukushima” (fail), and photographed hundreds of dead whales:


.. which have been duly shared all around Twitter again by people too immediately outraged to check anything about the source – as tracked down by Masa Kanagawa, the whale photo is from a 2010 report in New Zealand. And this strategy of posting hideous, nasty rubbish online in the hope of scoring clicks from social media appears to be doing pretty well – here’s Alexa’s report for the site:


.. which, of course, runs lots of adverts. Links make views, views make clicks, clicks make money. And, meanwhile, all around the world, thousands of people are misinformed. Services such as Twitter might have revolutionised the way that real news can be almost instantly disseminated, but they’ve also done the same for lies, half-truths and bullshit – when people quite happily believe anything that’s written on a news-like WordPress template, we’re all going to have to cope with the damage.

Oh, and in the “village” (prefecture) of Fukushima? The situation at the plant is still very bad, but outside the exclusion zone life goes on in one of the loveliest places I’ve ever visited – do go if you can.

* Note 1: The BBC didn’t actually link to the Voice of Russia report, it appeared in a web search result. But hey. On the scale of stupidity we’re dealing with here, this ranks fairly low.

How to remove “Who to follow” from Twitter

August 9th, 2010

Twitter’s new “Who to follow” thing is as dumb as a bag of rocks. Here’s how to remove it from Firefox in ten easy steps:

  1. Go here and install the Stylish Firefox extension. Restart when prompted.
  2. Click tools, then Add-ons.
  3. Click the new User Styles tab
  4. Click “Write new style”
  5. Give it the name Twitter_WTF, tag it Twitter
  6. In the main box, enter this: #recommended_users{display:none;}
  7. Click Save
  8. If there’s an Enable button, click it
  9. Close the Add-ons box
  10. Rejoice

Here’s how the new style should look:

You can enable and disable the style by right-clicking the Stylish icon in the bottom-right corner of Firefox and (un)ticking it. Thanks to @Yuuichi for posting the style rule last week.

Crushing predictability

January 16th, 2009

Further to my bitter ramblings about the way that every news event is followed by crap articles explaining how Twitter saved the day, yesterday evening a plane ditched in the Hudson river. Today, with crushing predictability, we get the Twangles – first from The Guardian (check out the headline) then from the BBC’s Rory Cellan-Jones, who amazingly found out about the crash at 21.45 thanks to the wonder of microblogging.

Great. Brilliant. Except that I found out a good hour earlier while waiting for a DLR train at Limehouse because it was already making the US news websites (picked it up on Gawker, followed it to MSNBC). Perhaps I should cough up a six hundred word article on this amazing new way to distribute news – you know, “news stories”. They’re a bit like tweets, but long enough to contain all the pertinent facts, correctly spelled and actually verified. Must. Inform. World.

Introducing Twangle, Twinute and Twingo.

January 6th, 2009

The Guardian, 19 May 2008 (link)

Why Twitter is the canary in the news coalmine

Last Monday, when an earthquake struck China’s Sichuan province, word of it spread quickly from witnesses on the shaking ground via Twitter, the mobile-and-web microblogging service where users share brief, 140-character-long updates with friends.”

The Guardian, 28 November 2008 (link)

Twitter comes of age with fast reports from the ground

From the moment the first shots were fired, the internet provided a kaleidoscopic view of events in Mumbai. Using blogs and file-sharing sites, those caught up in the mayhem rapidly provided accounts from the ground as well as links to the best news reports appearing on the web.

One rich source of information was Twitter, which provides text-message-length updates. Its Mumbai thread provided a stream of snippets, not all accurate, from observers on the ground, with details of casualties, sieges, gunfights, and even the suspected names of terrorists.

The Guardian, 1 December 2008 (link)

In Mumbai, witnesses are writing the news

Moments after the terrorist attacks on Mumbai began last week, Twitter exploded with messages. Prasad Naik, AKA krazyfrog, tweeted: “Firing happening at the Oberoi hotel where my sister works. Faaak!” Next, he reported that she had called and was safe. Then: “What the fuck! I just heard a loud blast! What the fuck is happening in Mumbai?” He was near a taxi blast in suburban Vile Parle. Nine hours later, his sister was home and he tweeted: “She saw piles of bodies. The Oberoi hotel guests. Staff members from her own department. All dead. Right in front of her eyes.”

The Guardian, 6th January 2009 (link):

What are you doing?

Wars have always been waged on all sorts of fronts. They have also, of course, always been about words: who asserts what; what different people mean when they say, “That’s mine.” The internet has vastly increased the ways in which people can have these arguments, and how directly they can have them, but even so it is huge step up to hold, as the Israeli consulate in New York did last week, a public, government-backed “citizens’ conference” on the social site Twitter – and then to keep replying to comments from all over the globe. It has proved massively popular: the consulate’s Twitter site (twitter.com/israelconsulate) yesterday afternoon had 3,739 followers, and at one point was posting a new comment, or answer to a comment, nearly every second.

We need a new term for a newspaper article that describes the impact of Twitter on a recent news event, and another to describe the ever-declining interval between the news event and said article. I’m suggesting “twangle” and “twinute” (“twinterval” has already been taken, sadly).

We could also set up a sort of bingo game (twingo, perhaps, like the cutesy French car). New twangle article? 5 points. Mention of Twitter in otherwise normal news piece? 1 point. Jeff Jarvis or Robert Scoble quoted? 2 points. Jeff Jarvis writes twangle, mentions Scoble? Twingo! You win!

Yes, I’m grumpy today. It’s too cold.