Overview
This is another article that talks about URL shortening services. Today we are going to talk about Cligs, one of the popular shortening services on the web.
Be prepared!Introduction

Today we are talking about another popular shortening service; it's
Cligs, one of the most popular
shortening services that provide lots of premium features for FREE.
Enough talking, let's begin the discussion.
In December 2009, Cligs acquired by Mister Wong (a very nice bookmarking service.)
Description
How Cligs can help you? Cligs gives you plenty of features, including the following:
- Shortening URLs (registered and non-registered users): You get a short URL that's no more than 20 characters (Tweetburner is 22 and is.gd is only 18) including the domain http://cli.gs.
- URL Management (registered users only): It allows you to manage your short URLs, to edit them, and to remove them if you like.
- Real-time Analytics (registered users only): How many clicked your link, and when.
- URL Previewing (registered and non-registered users): Preview the URL before opening it. Protects you from spam and unwanted sites.
API
Cligs provides you a very nice API with many advantages. The first advantage that we want to talk about is its simplicity. The API is very simple; it has just two functions, one for shortening URLs, and the other for expanding short URLs (to expand a URL means to get the long URL from the short one.)
Another advantage of this API is that it allows you to shorten the URLs whether you are a registered user or not. Of course a registered user need to get an API key in order to link the API calls to his accounts so he can manage the links generated by the API and to watch the analytics.
Shortening URLs
The first function is used for shortening URLs and it's called, create. This function has the following address:
http://cli.gs/api/v1/cligs/create?url={1}&title={2}&key={3}&appid={4}
The API is still in version 1, that's why you see 'v1' in the address. This function takes four parameters, only the first one is required, other parameters are used for authentication:
- Url: Required. The URL to be shortened.
- Title: Optional. For authenticated calls
only. The name that would be displayed on the short URL in your control
panel (used for managing your URLs.)
- key: Optional. If you are a registered user
and you want to link the API calls to your account, you'll need to enter
your API key here.
- Appid: Optional. If you have used an API key, then you have to provide your application name that used to generate this API call (help users know the source of the link.)
So how can you use this function? If this is an anonymous call (i.e. no authentication details provided,) just call the function providing the long URL in its single required argument.
If you need to link this call to a specific account, then you'll need an API key, which the user can get by signing in to his Cligs account, choosing 'My API Keys', then clicking 'Create New API Key' (if he doesn't have one you.) The last step generates an API key that's no exactly 32 characters (see figure 1.)
After you get the API key, you can push it to the function along with your application name in the appid argument.
What about the title argument? For registered users, they can access their clig list (see figure 2) and see the URLs they shortened and the titles they choose above each of the URLs.

Now, let's code! The following function makes use of the Cligs API to shorten URLs. It accepts three arguments, the long URL, the API key, and the application name. If the API key is null (Nothing in VB.NET,) the call is made anonymously, otherwise, the API key and the application name are used.


Mike GoldPosted Sep 2, 2010, 12:03 AM
Thanks Mohammad, that's a thorough explanation of how to use CLIGS in .NET.