The main point of this post is to remind myself of how to solve a problem in the unlikely event that I encounter it again. If anybody else with the same problem stumbles across it, so much the better.
In these modern times, it is easy to quote a tweet on a wordpress blog post – you just put in its url and a kind of magic happens. Back in the olden days, life wasn’t as easy as that, but there was a third party plug in called Blackberry Pie which performed an equivalent function. It broke with an api change years ago, but I still have a handful of its shortcodes scattered across long ago posts.
Most of them are easy enough to fix – the shortcode includes the full link to a tweet which is easily extracted. But Blackberry Pie was smart enough to cope with just the tweet id, and there is no apparent way of recreating the full tweet url from that, since links always include the twitter username.
So I turned to Twitter itself for help.
Twitter question: given the ID number of a tweet (the long number in the url) but not the account name, is there any way of finding it?
— Stefan Czerniawski (@pubstrat) May 20, 2015
And help there quickly came.
— Simon Dickson (@simond) May 20, 2015
That looked good in theory, but I couldn’t make it work in practice non-programmatically, even with the authentication keys. Not to worry, more help was to hand.
— Chris Yiu (@clry2) May 20, 2015
Well I don’t particularly python, but I was game to try, though this was starting to turn into a more serious enterprise than the size of the task seemed to warrant.
But then I struck gold – though I nearly missed it.
— Josh M. (@desire_line) May 22, 2015
My first thought was that this had missed the point altogether. The link structure
still seemed to need me to know what to put in for the placeholder
Tweet_Maker_User_Name, which was precisely the problem I had in the first place. But then it occurred to me that perhaps it was a special code which effectively did the job of the api call and that only
Tweet_ID needed to be substituted. And so it proved. The link resolved to the full standard url, username and all. Job done.
But I was still a bit curious about the apparently generic username placeholder and wondered whether it was documented. A search produced precisely one result, a Stackoverflow discussion of the question I had started with. One contributor suggested the
Tweet_Maker_User_Name approach – and was squashed by another who made the same misjudgement I had. But the final reply gives the answer I had begun to suspect, that the link structure is not so much
Indeed, even substituting a valid but incorrect username doesn’t cause a problem, the link still resolves to the correct full url, fixing the wrong username as it goes.
Which leaves me with the intriguing twin thoughts that the use of usernames in twitter urls is to help human readers rather than having any technical significance, and that this redundancy appears to be very little known.
And a final serendipitous twist. The Stackoverflow question was posted on 22 May 2009, six years almost to the day before I was looking for the answer. It’s attracted a leisurely eight responses over those six years, the last and most useful of which was posted on 17 May 2015, immaculately timed to be there when I looked for it.
Thanks to Simon Dawson, Chris Yiu and Joshua Mouldey