新浪短链接t.cn API接口服务说明

接口格式:http://sina-t.cn/api?link=长链接

长链接格式:请带上http://或者https://协议头

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

   对接有问题?请联系细雨客服QQ:1960520477。 欢迎前来洽谈!

接口调用代码演示/ DEMO(长链接以百度地址:https://www.baidu.com说明)

PHP调用代码:

$url = 'http://www.baidu.com';

$api_url = 'http://sina-t.cn/api?link='.urlencode($url);

$short_url = file_get_contents($api_url);

echo $short_url;
				

JAVA调用代码:

public static void main(String path[]) throws Exception {
URL u = new URL("http://sina-t.cn/api?link=http%3A%2F%2Fwww.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://sina-t.cn'
path = 'api'
method = 'GET'
querys = 'link=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)
				
关于细雨短网址服务 | 联系我们 |
Copyright © 2011-2019 细雨短网址, All Rights Reserved