我正在尝试构建一个 jQuery 函数,该函数将允许我出于微博原因(是的,twitter)从其他链接生成 TinyURL ...我从 James Padolsey 找到了本教程,但没有得到回复称呼。
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);
});