Home Install Firefox Extension Use API Blog Apps
Make your apps better with Long URL Please
URL: http://longurlplease.appspot.com/api/v1.1 (optional https)
Format: JSON (application/json)
Methods: GET
q
- url to lengthen. Multiple values allowed (up to 10 are decoded).
callback
- (optional) if provided, then response will be wrapped in a call to this function.
Calling API with multiple values for 'q' paramater.
curl 'http://www.longurlplease.com/api/v1.1?q=http://bit.ly/enAo&q=http://short.ie/bestxkcd'
{"http://short.ie\/bestxkcd": "http:\/\/razvan784.blogspot.com\/2007\/09\/best-of-xkcd.html",
"http://bit.ly\/enAo": "http:\/\/www.boasas.com\/?c=1030"}
Calling API with a callback function.
curl 'http://www.longurlplease.com/api/v1.1?q=http://bit.ly/enAo&callback=withFunk'
withFunk({"http://bit.ly\/enAo": "http:\/\/www.boasas.com\/?c=1030"})
To save you writing your own custom javascript - we provide a simple library that will cover most usages, and currently supports jQuery, flXHR and Adobe Air applications.
<script type="text/javascript"
src="http://www.longurlplease.com/js/longurlplease.js"></script>longurlplease.lengthen();
longurlplease.lengthen takes an options hash
* Requires JSON parser
If you are using jQuery then the longurlplease javascript library will act as a plugin to jQuery adding functions to lengthen short urls.
Use longurlplease function to replace short urls with their originals.
$('#to-replace').longurlplease();
or to replace all short urls in the document, simply
$.longurlplease();customise behaviour with options:
$.longurlplease({lengthenShortUrl : function(aTag,longUrl){...}});
To demonstrate that you have fine control over which parts of your document to change, only the first set of links will be lengthened.
$("button#run-demo").click(function () {
$(this).hide();
$("#pleaseLengthenMe").longurlplease();
});
More information in this blog post. Check out the sample project.
flXHR allows cross domain client to server requests. It exposes a Javascript api identical to XMLHttpRequest but allows cross domain requests thanks to some flash goodness and crossdomain.xml policy files.
Using flxhr with longurlplease is a breeze - simply set the transport option to 'flxhr' and make sure you've the necessary flxhr files included in your page.
Check out this demo for a working example.