Twitter Detective MasterHack: How To Retrospectively Find A User ID Number

Tuesday, 21 May 2019
Bob Leggitt
An introduction to the wonderful world of advanced Twitter forensics.
Twitter masterhack
Photo by Yucel Moran on Unsplash

I wrote in my Old Usernames article about the importance of Twitter's User ID in keeping tabs on slippery people's behaviour. The User ID is a unique account identifier which remains the same however many times the user changes his or her @username. If you know the User ID, you will always be able to find a given Twitter profile (or at least find what's happened to it) via its numerical URL.

But what happens if you discover that, say, a group of account @usernames have been switched, and you need to actually prove that the switch has taken place? This can happen with account networks when they try to cloak their origins. And it became important recently when the lead profile in a network of raving political activist accounts rebranded as the main promo feed for an alternative social media platform, claiming to be politically impartial. I know, you couldn't make it up, could you?

"What happened to that original @google account? Has it been repurposed? Let's find out..."

I'm not going to publicise the account in question, but it turned out to have gone through at least six @usernames, and it was originally a promo feed for a pitifully unprofessional "travel site". I wanted, however, to be 100% sure that my old username tracking investigation was entirely accurate. Before I presented the info to anyone else, I needed to be right. And to be absolutely certain, I needed to retrospectively access the User IDs of accounts in the network - as they applied in the past. That would confirm beyond doubt that the usernames had been switched. But how would I get that confirmation?...

WAYBACK MACHINE TO THE RESCUE

The Internet Archive, or Wayback Machine, captures web pages and preserves them for the future. It doesn't capture everything on the Internet, but when a page gains serious traction, the Archive will almost invariably pick it up.

So with significant Twitter accounts that switch their @usernames, you can find a full representation of the profile pages, as they were at various dates in the past. You can then check the source code for each page and categorically tie the old @username to a User ID. I'll explain all this so that anyone can do it. You won't need to understand code.

The one proviso is that the @username(s) you want to review must still exist live on Twitter. The Internet Archive will not display pages that are inaccessible. So if an account bearing one of the @usernames is suspended, or deactivated, you probably won't find it in the Archive. However, if the @usernames have only been switched and not deleted or zapped, everything is still fair game for the Archive to display.

If one @username has simply been dropped - that is, it doesn't currently exist on Twitter but is not suspended and is available for re-use - then setting up a new account with that @username may restore the original page to the Archive. This obviously depends on whether the Archive captured the original page in the first place though.

Even if you're not seeking a retrospective User ID, looking up Twitter pages retrospectively on the Internet Archive can be fascinating. You can find how many followers the user had at a point in the past, for example. This is a facet of history that Twitter itself doesn't inherently reference, but it's sometimes useful to know.

When Twitter had its big bot purges, a lot of the people who'd bought followers, but had always insisted they hadn't, lost tens of thousands - even hundreds of thousands of followers overnight. It was great fun to check their recent entries on the Internet Archive and measure their exact losses. Indeed, the profile at the centre of the @username-switching episode I was investigating, had itself lost six digits of followers during a bot purge.

THE PROCESS

So, returning to the plot, Step 1 in the process is simply to go to the Internet Archive, and enter the full URL of the Twitter page you want to find. I'm using the @google username for my example, and here's the format of the URL...

htt​ps://twitter.com/google

screenshot

If the Archive has never captured pages for your chosen @username, you'll get no results. But if it has, you'll go to a calendar page, where you can select the year, and then any date for which a capture is available. As seen below...

screenshot

ACCESSING THE SOURCE CODE

Once you've clicked through from the calendar to an actual archived profile page, you see an old version of the page on the URL you entered, like this...

screenshot

Accessing the source code for that page is easy. Just right-click any blank space on your archive page in any major browser, and select View source code, View page source or similar from the context menu. See below...

screenshot

This will open up a page of code, which to many people will look like gobbledygook.

DON'T PANIC! You don't have to make sense of the code page. All you need to do is search for the User ID in your browser's search box. Here's how you do it...

FINDING THE USER ID IN THE SOURCE CODE

On the code page, press Ctrl+F to open your browser's search function. Now you'll just need to paste a short line of code into that search box. But bear with me for a moment...

The composition of Twitter's pages has changed over the years, so while the User ID does appear in all of them, the way it's displayed differs depending on how far you want to go back in time. The good news is that the ID has been displayed in the same way as far back as around early to mid 2013 (a rollout period). So provided you don't need to reference anything before that, here's the line you need to enter into your browser's search box, on the source code page...

similar_to_user_id&q​uot;:

Here's the actual code page, with the above text pasted into the browser-search box...

screenshot

When you copy, paste and search that line, you should see it highlighted on the source code page, and there'll be a number immediately after the highlighted line. That number is the User ID. See the screen shot below...

screenshot

So now all you do is copy the number (and you ONLY want the number - nothing else), and add it onto the end of this line..

htt​ps://twitter.com/intent/user?user_id=

@google's User ID for 1st July 2014 was 20536157, so here's how the complete line would look in my example case...

https://twitter.com/intent/user?user_id=20536157

Now just paste the whole line into your browser URL bar, as shown below...

screenshot

This is the moment of truth! If you see the same @username and account identity that appears in the Archive, the @username has not been switched. But if you see a different account identity, you have your proof that this account, used to be that account. In the case of @google, we see that the username has not been switched...

screenshot

If you need to go back further than 2013 on the Archive, you'll have to search different code phrases in the source code to locate the User ID.

For between around early to mid 2011 and around early to mid 2013, copy, paste and search this line...

data-user-id=

Depending on the date, you may need to go down the page a couple of times until you find one with a number after it.

Before around early to mid 2011, search this line...

statuses/user_timeline/

"NONE OF THE OPTIONS WORK" - AN UPDATE...

Twitter has changed enormously since this article was written, and I no longer advocate using the platform at all. All Twitter pages are now served programmatically, which means that the User ID is no longer contained in the basic page source. Reliably getting hold of a user ID from the Internet Archive for entries more recent than this article's publication date is moving beyond the scope of a guide intended for a non-technical audience, but here's some up-to-date info circa May 2023...

For archive captures taken earlier than the 2019 publication date of this article, you should still be able to grab the User ID using the methods described in the original text above.

For more recent archive captures, the original methods will no longer find the User ID. Because Twitter's pages are now programmatically served, the only universally reliable way to extract a User ID from a Twitter page is to monitor the live network traffic via your browser's Inspector console and catch the app making calls to the API. This is a developer-level action, and it can get a lot more complicated than the original article was meant to be. It's also not possible to dive into the network calls on the Internet Archive, because IA doesn't provide a live page - it's just a static capture.

However, when a profile page has a header picture - known as the profile banner - the User ID is contained within the URL of that image. So, to get the ID from a Twitter header image on the Internet Archive...

Load the profile page on the Internet Archive as described.

Right-click on the profile page's header image at the top of the screen.

Select "Copy Image Link" (Firefox) or "Copy Image Address" (Chrome) from the context menu.

Paste the link you've just copied in a place where you can see it - in a notepad, for example.

It will look something like this...

https://web.archive.org/web/20230106093641im_/https://pbs.twimg.com/profile_banners/783214/1646075315/1500x500

The User ID will be the number that appears immediately after profile_banners/ - as highlighted in yellow above.

Most accounts do have a profile banner, so it's normally still possible to extract an ID in this way. But Web technology in general is becoming hugely more complex. So I'm now going to leave this article as is, with the reminder that it was written in spring 2019, and that the evolution of webtech is relentless.

END OF UPDATE

We can use a very old search to find out something interesting about @google's Twitter account history. I noticed when inspecting the current @google profile that the join date is February 2009. But the Internet Archive shows the existence of @google tracing back to at least March 2007. That means the earliest Archive entries for @google, between March 2007 and January 2009, must relate to an account with a different ID. So what happened to that original @google account? Has it been repurposed? Let's find out...

screenshot

As you can see above, the old User ID was 764150, so let's see where that now leads...

https://twitter.com/intent/user?user_id=764150

screenshot

There's your answer. The old account was deactivated, and is no longer live. But this is a great illustration of the way the Internet Archive can even show us deleted Twitter accounts, as long as the @username still exists somewhere on the current Twitter.

I can't imagine you'd want to go back before early to mid 2007, but if you do, try searching this in your page source code...

user/profile_image/

So, now you have a nice bit of specialist Twitter detective hacking knowledge, you fiendish genius, you.