腾讯短网址(url.cn) 2020最新腾讯短网址API接口推荐

url短链接最开始是为了对抗http://t.cn推出的网址压缩服务,后来其微博倒闭,官方并没有停止http://url.cn的解析,但也没有对外开放接口。 后面从搜狗流出了一个内部的API接口。但是由于使用的人太多了。导致去年搜狗关闭了那个接口!导致很多朋友没有办法在使用腾讯短网址了。今天我就给大家推荐几个平台。都是支持API接口生成以及在线批量生成的。满足技术开发人员和小白用户的使用!

API接口地址

腾讯短网址(http://url.cn)

接口1:http://www.sinadwz.cn/url/dwz.php?url_long=http://www.baidu.com

接口2:http://maiyurl.cn/tengxurl?url_long=http://www.baidu.com

接口3:http://www.sina-url.cn/txdwz.php?url_long=http://www.baidu.com

在线生成地址

腾讯短网址(http://url.cn)

接口1:http://www.sinadwz.cn

接口2:http://maiyurl.cn

接口3:http://www.sina-url.cn

新浪短网址接口

新浪短网址(http://t.cn)

接口1:http://www.sina-url.cn/xinlang?url_long=http://www.baidu.com

接口2:http://www.qqdwz.cn/urlcn/api?url_long=http://www.baidu.com

接口3:http://maiyurl.cn/weibourl?url_long=http://www.baidu.com

新浪短网址(http://t.cn)

接口1:http://www.sina-url.cn

接口2:http://www.qqdwz.cn

接口3:http://maiyurl.cn

注意事项:

① 调用api接口时,只需将 “http://www.baidu.com”换成需要缩短的长网址即可。

② 接口支持url参数,当url中出现 & 符号时,请用 %26 代替(或者使用url编码格式),否则参数可能会丢失。

③ 填写url时,必须要以http(s)://开头,否则可能会导致生出的短网址无法访问原网站。

常见问题:

① 长链接转换,为什么结尾的参数丢失了?

答:因为url中含有特殊字符,需要使用UTF8编码格式,将url编码

② 接口没有返回结果,是什么情况?

答:有些时候接口返回数据会有延迟,延时未返回则会提示生成失败;或者是因为原链接被封了。

API接口文档说明

PHP调用演示:

$url = 'http://www.baidu.com';
$api_url = 'http://www.qqdwz.cn/tcn/api?url_long=http://www.baidu.com;
$short_url = file_get_contents($api_url);
echo $short_url;

JAVA调用演示:

public static void main(String path[]) throws Exception {
URL u = new URL("http://www.qqdwz.cn/tcn/api?url_long=http://www.baidu.com");
InputStream in = u.openStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
byte buf[] = new byte[1024];
int read = 0;
while ((read = in .read(buf)) > 0) {
out.write(buf, 0, read);
}
} finally {
if ( in != null) {
in .close();
}
}
byte b[] = out.toByteArray();
System.out.println(new String(b, "utf-8"));
}

Python调用演示:

import urllib, urllib2, sys
host = 'http://www.qqdwz.cn '
path = 'sina.php?url_long='
method = 'GET'
querys = 'url=http%3A%2F%2Fwww.baidu.com'
bodys = {}
url = host + path + '?' + querys
request = urllib2.Request(url)
response = urllib2.urlopen(request)
content = response.read()
if (content):
print(content)

猜你喜欢

转载自www.cnblogs.com/zaqa001/p/12469346.html