我正在尝试构建一个jQuery函数,它将允许我从其他一些链接生成一个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);
});发布于 2009-07-10 18:50:19
嗯,这对我来说似乎很好用:
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');https://stackoverflow.com/questions/1111171
复制相似问题