I use bitly.com for shortening some of my URLs. There are API Libraries and Documentation for bitly, so it is possible to write your own bitly-related applications. In this post, I'll show you two examples of such applications - one built in Flex and AS3 and another in ColdFusion's CFML. |
Flex-based version :
The Flex-based version works like this:
-
Leveraging Flex and AS3, I put together a BitlyOHoney.swc that accepts four inputs - your bitly API credentials (bitly Username and bitly APIKey), a long URL, and the format of the response data (XML, JSON, and TXT). Once you register on the bitly.com site, you can retrieve your API credentials and use them to try out this example. Take a look at the API Libraries and Documentation for bitly for more information.
-
According to the API, all bitly APIs support an optional return format parameter. * Note that json is the default response format. but xml is also available. Some endpoints also support a simple txt format. While creating my example appication, I learned that the response format you use in applications need to be lowercase (xml, json, txt and not XML, JSON, TXT). Also, note that the format, txt, is not spelled text.
-
According to the API, long URLs should be URL-encoded. I use the escape(long URL) function in my Flex/AS3-based example.
-
In this version, I leverage a Flash-based SharedObject to locally store the Bitly API credentials, saving keystrokes for subsequent URL shortening generation.
Click to try out the Flex-based version.
ColdFusion 9 version :
The ColdFusion 9 version works like this:
-
A CFML-based page is used to collect four inputs - your bitly API credentials (bitly Username and bitly APIKey), a long URL, and the format of the response data (XML, JSON, and TXT). Once you register on the bitly.com site, you can retrieve your API credentials and use them to try out this example. Take a look at the API Libraries and Documentation for bitly for more information.
-
The CFML-based page calls a ColdFusion Component function that leverages the CFHTTP tag to 'GET' the bitly API response.
-
According to the API, long URLs should be URL-encoded. I use the URLEncodedFormat(arguments.longURL, "utf-8") function in the CFC to urlencode the long URL.
Click to try the ColdFusion-based version.
Tip Jar:
|