I'm trying to build a jQuery function that will allow me to produce a TinyURL from some other link for micro blogging reasons (yes, twitter)... I found this tutorial from James Padolsey, but am not getting a response back from the call.
http://james.padolsey.com/javascript/create-a-tinyurl-with-jsonp/
function requestShortURL(longURL, success) {
var API = 'http://reque.st/create.api.php?json&url=',
URL = API + encodeURIComponent(longURL) + '&callback=?';
console.log('tweet apit url: ' + URL);
$.getJSON(URL, function(data){
success && success(data.url);
});
}
requestShortURL('http://www.mycompany.com', function(shortened){
alert('new url: ' + shortened);
});
Hm that seems to work fine for me:
function makeTinyUrl(url)
{
$.getJSON('http://json-tinyurl.appspot.com/?url=' + url + '&callback=?',
function(data)
{
alert(data.tinyurl);
}
);
}
makeTinyUrl('http://stackoverflow.com/questions/1111171/how-to-use-jquery-to-produce-tinyurl');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With