Welcome to Brad Arsenault's open-source URL shortener!
see more info down below to learn more about what this does
Shorten A URL
This code, all written in Perl, is a sum of a about 10 hours of work, starting in early February 2010.
This service, probably unlike many, is entirely Perl (and CSS and HTML and jQuery for Ajax). No PHP.
So, without further adieu, here is how this works:
For you, the user:
I offer the following:
The first form (shorten a URL):
- You can enter (copy/paste or type) a URL to be shortened into the "URL" box. You can simply hit (enter/return) to submit this and retrieve your shortened URL or...
- The second field has been auto-filled for you with a short code, the code that will be used to access the long url in the future. You can edit this to be whatever you want (A-Z and 0-9 only) or hit the space bar twice to get another random shortcode.
The second form (expand a URL):
- Here you provide two bits of infomation to the server: the short code (already existing)
- And also the API you wish to use (how you wish to get the information) -- the default will simply show you the long URL, however you can chose any of the others at your whim.
Geek-y information follows...
- 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 expand-er function on this page.
- 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), not really useful, see option #2
- api=2 // a TinyURL style printout (just prints out $baseURL + shortcode), the easiest API possible!
Interested? Check here
for more information about this project.