I've got a twitter plugin that prints t.co links. How can I 'un-short' them with jQuery? Is there a library I could use?
I did some searches but I can't find anything. Maybe I'm searching on the wrong thing...
I've got a twitter plugin that prints t.co links. How can I 'un-short' them with jQuery? Is there a library I could use?
I did some searches but I can't find anything. Maybe I'm searching on the wrong thing...
I made a fiddle here: http://jsfiddle.net/duotrigesimal/XB8Uf/
It makes a request to the api at LongURL (http://longurl.org/api#expand-url) to get the expanded url.
var tests = [
'http://t.co/NJwI2ugt',
'http://www.google.com' //nothing should happen
];
var expander = {
expand: function (url, callback) {
$.ajax({
dataType: 'jsonp',
url: 'http://api.longurl.org/v2/expand',
data: {
url: url,
format: 'json'
},
success: function(response) {
callback(response);
}
});
}
};
for(i in tests) {
expander.expand( tests[i], function(response) {
$('#output').append(response['long-url']+'<br>');
console.dir(response);
});
}