Shrinking your Url’s is all the rage nowadays. If you are on Twitter, then odds are you have used one. Despite CodingHorror’s distaste for them in his recent blog post on Url Shorteners: Destroying the Web since 2002, they are a fact of life when we live in a world of 140 character status updates.
So what’s a URL shrinking service anyway? Well, to put it simply, you supply them with a URL, they then supply you with a shorter URL containing a lookup “key”. When future requests are made to this shorter URL, connections are routed to that services website where they convert the short URL to the original URL and issue a HTTP Redirect back to your browser to send you off to the original long url website.
So, what’s a guy, or gal, to do if they want to set their status programmatically on Twitter, Facebook, FriendFeed, or the other gazillion social networking sites out there today and need to post a very long URL? Most of these shrinking services offer API’s to access their “shrinking” services so it’s just a matter of digging into the various APIs to get them implemented. In my original PowerShell Twitter library PoshTweet, I included support for a couple for shrinking URL’s through a couple of shrinking services but I figured it would be good to separate that functionality out into it’s own library.
So, here’s my first stab at a generic URL shortening library for PowerShell. I’ve included the following services:
Some of these services have advanced features such as statistical reporting on all your submitted links. Those services require users to create accounts and register for API keys. Bit.ly is one of them, so if you want to use that service, you will have to supply this script with your bit.ly username and API key with the Set-BitlyServiceInfo function.
So, here’s the script, hope you all enjoy!