利用新浪API生成网址短链接
js
var convertStr = encodeURIComponent(urlStr); //转码
var appkey = 'xxx';
getShortUrl(convertStr);
function getShortUrl(urlStr) {
$.ajax({
type: 'GET',
url:
'http://api.t.sina.com.cn/short_url/shorten.json?source=' + appkey + '&url_long=' +
urlStr, //source为新浪appkey
dataType: 'JSONP',
json: 'callback',
data: {},
success: function(r) {
return r[0].url_short; //生成的短链接
}
});
} 继续阅读与本文标签相同的文章
-
Windows Mobile远程控制软件Pocket Controller Pro简介
2026-05-23栏目: 教程
-
VB实现SHELL扩展之接口参数获取失败探析
2026-05-23栏目: 教程
-
西门子Prodave5.5使用说明及VC示例
2026-05-23栏目: 教程
-
16进制字符串转数字(C/C++,VB/VB.net,C#)
2026-05-23栏目: 教程
-
PPC与PC无线连接(Wi-Fi)
2026-05-23栏目: 教程
