天天看點

騰訊短網址線上生成(url.cn短網址) 2020最新騰訊短網址生成api接口推薦

短網址生成指的是把幫您把冗長的URL位址縮短成8個字元以内的短網址。目前市面上的短網址品牌很多很多,但是最常見的還是下面說的幾種:

騰訊短連結:url.cn

淘寶短連結:c.tb.cn

新浪短連結:t.cn

百度短連結:dwz.cn

騰訊短網址(url.cn)就是使用騰訊的API接口将冗長的連結轉換成超短的url.cn連結。使用url.cn短網址更易于使用者記憶,利于使用者轉化。

url短連結最開始是為了對抗http://t.cn推出的網址壓縮服務,後來其微網誌倒閉,官方并沒有停止http://url.cn的解析,但也沒有對外開放接口。

優點:穩定性好,故障率極低,很少出現異常,微信裡被封機率比較低

用的多的就是騰訊短網址,是以我們重點講下騰訊短網址

① 調用api接口時,隻需将 “http://www.baidu.com”換成需要縮短的長網址即可。

② 接口支援url參數,當url中出現 & 符号時,請用 %26 代替(或者使用url編碼格式),否則參數可能會丢失。

③ 填寫url時,必須要以http(s)😕/開頭,否則可能會導緻生出的短網址無法通路原網站。

PHP調用示範:

$url = ‘http://www.baidu.com’;

$api_url = 'http://www.qqdwz.cn/tcn/api?url_long=http://www.baidu.com;

s h o r t u r l = f i l e g e t c o n t e n t s ( short_url = file_get_contents( shortu​rl=fileg​etc​ontents(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)

當然其他短網址和接口都有

騰訊短網址線上生成(url.cn短網址) 2020最新騰訊短網址生成api接口推薦
騰訊短網址線上生成(url.cn短網址) 2020最新騰訊短網址生成api接口推薦

歡迎試用,接口位址:https://url.cn/XPLBmy2R