the link shrink
Return to the homepage

The L2L.at javascript API

To incorporate the L2L.at URL shrinker into your own site, the only requirements are:
  • registration to L2L.at
  • attachment of the L2L.at javascript file to your page

Upon registration, you will be assigned an API key.

Armed with your API key you can then attach the script to your page. Inside the <head> tag place the following:

<head>
<title>Webpage title</title>
<script type="text/javascript" src="http://l2l.at/api_[API_KEY].js">
</script>
</head>
<body>
...
</body>

Be sure to replace [API_KEY] in the above with your API key

You can now access the power of L2L.at from your own javascript

Try this example:

<head>
<title>Webpage title</title>
<script type="text/javascript" src="http://l2l.at/api_[API_KEY].js">
</script>
<script type="text/javascript" language="JavaScript" >
function shrunk(reply) { // this is your callback function
if (reply["error"]) {
alert(reply["error"]);
}else if (reply["url"]) {
alert(reply["longurl"]+" has been shrunk to "+reply["url"]+" with title '"+reply["title"]+"'");
}
}
</script>
</head>
<body>

<a href='javascript:L2Lshrink("www.polyfex.com","shrunk")'>
Example 1: Shorten www.polyfex.com fully
</a>

<a href='javascript:L2Lshrink("www.polyfex.com","shrunk","Polyfex")'>
Example 2: Shorten www.polyfex.com quickly
</a>

</body>

The function ‘shrunk’ is the callback, that you wish the result to be sent. The result is sent in the form of an array with key/values pairs.

If the operation is successful the resulting array will have keys:

  • url: the new shrunken URL
  • title: the page title of the linked webpage
  • longurl: the linked URL

If the operation is not successful the resulting array will have only one key:

  • error: the error message

Calling the shrinking process is simple and shown in the 2 examples above:

Example 1: Calls the javascript function L2Lshrink with two arguments

  • The URL to be shortened
  • The callback function you want to result to be sent to

With two arguments, L2L.at is requested to load the linked page and retrieve the page title.

Example 2: Calls the javascript function L2Lshrink with three arguments

  • The URL to be shortened
  • The callback function you want to result to be sent to
  • The page title to store (if not already shrunk)

With three arguments, L2L.at is NOT requested to load the linked page and therefore is a far quicker request.

Note: If a URL is submitted that has already been shrunk then the page will not be fetched by L2L.at, and the existing record will be returned. All links that have been submitted can be viewed by loggin in to L2L.at

 

Login

Register

Why?

Registered users can keep track of the number of clicks each link gets over the previous year or the current month.

Developers can also include l2l.at functionality in their own sites, with a simple http request and an api secret.

Easily Shrink your Links from your browser with the ‘Shrink this!’ hyperlink found in the footer of this page.

Just drag this link to your browser’s toolbar. When you find a page you want to post on another site, but the address is long, you will then be able to click on ‘Shrink This!’ and the URL will be loaded into L2L.at, automatically.