This is the total of 4 hours work on a Friday night and a few sparse hours since.
This service, probably unlike many, is entirely Perl (and CSS and HTML). No PHP. I could get into why I... uhhh... "dislike" PHP, put this is neither the time nor the place for that... I HAVE A BLOG!.
So, without further adew, here is how this works:
- There are two scripts - index.pl and shorten.pl. Here are the API calls for index(expands URLs):
- api=1 // basic redirect (counts as view)
- api=2 // expands URL in plaintext (in ode to TinyURL)(counts as view) BTW this is the API used to power the Ajax-y quick expander on this page ("Quick Expand")
- api=3 // webpage showing stats on the URL, same information outputted as with JSON (doesn't count as a view)
- api=4 // JSON [bit.ly style] printout: provides:
- Short code that was provided ("shortCode")
- total times the url has been accessed (minus the api=4 and api=3) ("views")
- unique views by IP ("uniqueViews")
- time and date it was created... in TWO FORMATS!: epoch ("createdEpochTime") and long form ("timeDateCreatedLongForm")
- Time/date of last visit... also in two formats! epoch ("epochLastVisit") and long form ("timeDateLastVisitLongForm")
- the number of other short codes in the database which point to the same URL
- ...and finally the expanded URL in plaintext
- The second script, shorten.pl does all of your shortening needs! Here are it's API calls:
- api=1 // a webpage with the new URL short code (feature will be expanded)
- api=2 // a TinyURL style printout (just prints out $baseURL + shortcode), the easiest API possible!
BTW if you're so interested, this is also what powers the Ajax-y version of the "Quick Shorten" button.