Skip to content

Commit

Permalink
Adding hurl.im url shortener
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarsa committed Feb 15, 2011
1 parent 3959894 commit edb3de9
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion lib/shortener_lib.js
Expand Up @@ -55,7 +55,7 @@ BitLyShortener = {
url: url,
data: params,
dataType: 'json',
success: function(data, status) {
success: function(data, status_param) {
var status = data.status_code;
if(status == 200) {
callback(0, data.data.url);
Expand Down Expand Up @@ -423,6 +423,34 @@ VaMuShortener = {
}
};

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

SHORTENERS_BACKEND = {
bitly: {
desc: 'bit.ly',
Expand Down Expand Up @@ -492,5 +520,9 @@ SHORTENERS_BACKEND = {
vamu: {
desc: 'va.mu',
backend: VaMuShortener
},
hurlim: {
desc: 'hurl.im',
backend: HurlimShortener
}
};

0 comments on commit edb3de9

Please sign in to comment.