Skip to content

Commit

Permalink
Adding URLi.nl shortener. Closes #95
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarsa committed Feb 8, 2010
1 parent 90e80d6 commit 6a2ae54
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion lib/shortener_lib.js
Expand Up @@ -175,7 +175,7 @@ MiudinShortener = {
}

TwieatShortener = {
shorten: function(longUrl, useAcct, login, apiKey, callback) {
shorten: function(longUrl, useAcct, login, apiKey, callback) {
var url = "http://twieat.us/shorturl.jsp";
var params = {
mode: 'api',
Expand All @@ -198,6 +198,34 @@ TwieatShortener = {
}
}

URLinl = {
shorten: function(longUrl, useAcct, login, apiKey, callback) {
var url = "http://urli.nl/api.php";
var params = {
format: 'json',
action: 'shorturl',
url: longUrl
};
$.ajax({
type: 'GET',
url: url,
data: params,
dataType: 'json',
timeout: 6000,
success: function(data, status) {
if(data && data.status && data.status == 'success') {
callback(0, data.url.keyword);
} else {
callback(data.statusCode, data.message);
}
},
error: function (request, status, error) {
callback(-1, 'AJAX request failed (bad connection?)');
}
});
}
}

SHORTENERS_BACKEND = {
bitly: {
desc: 'bit.ly',
Expand Down Expand Up @@ -233,5 +261,10 @@ SHORTENERS_BACKEND = {
desc: 'twieat.us',
baseUrl: 'http://twieat.us/',
backend: TwieatShortener
},
urlinl: {
desc: 'URLi.nl',
baseUrl: 'http://urli.nl/',
backend: URLinl
}
}

0 comments on commit 6a2ae54

Please sign in to comment.