Building an "On This Day" site for your Twitter Account
I wanted to see what I was Tweeting on this exact day last year. And all the years before. So I built a website! It's a disgusting hack, and I'm truly sorry for unleashing it on you.
Using the API
You can't.
The Twitter search API only goes back 7 days. This whole idea would be much easier if I had access to the Premium API.
But! The Twitter website has no such restrictions.
Advanced Search
Twitter's Advanced Search allows you to pick specific dates to search for. Here's the string which shows my username's Tweets on Christmas day 2015: search?q=from:edent (until:2015-12-26 since:2015-12-25)
So how do we embed Twitter's site on our page?
iFrames!
Nope!
Twitter's X-Frame-Options Policy doesn't allow embedding. Oh well. Guess we have to give up.
HA!
Busting makes me feel good
Using the X-Frame Bypass Web Component is a real-life cheat-code.
X-Frame-Bypass is a Web Component, specifically a Customized Built-in Element, which extends an IFrame to bypass the
X-Frame-Options: deny/sameorigin
response header. Normally such headers prevent embedding a web page in an<iframe>
element, but X-Frame-Bypass is using a CORS proxy to allow this.
It's dead simple to use. Stick this in your <head>
HTML<script type="module" src="https://unpkg.com/x-frame-bypass"></script>
Done.
Stick it all together.
I wrote some horrible code to shove a dozen iFrames on a page. Ta-da!
The frames each point to the mobile version of the Twitter site - that provides a single column layout. The X-Frame Bypass doesn't send a User Agent Header - which is lucky because it forces Twitter to serve up a legacy version of the site.
It only loads 20 Tweets per day - so you'll need to click through if you were particularly loquacious that day.
I can't be bothered to release this as a proper site. But if you want to - go ahead!
Lauren Currie OBE said on twitter.com:
Yay! So fun. Thanks for sharing
Marc Blank-Settle said on twitter.com:
that’s really clever, although you lose points for “Busting makes me feel good”
Philippe Elsass said on twitter.com:
Aw how did I forget that this service existed