api文档/ API

名称 说明
  接口地址 http://api.migourl.cn/tcn/api?key=用户KEY&url=http%3A%2F%2Fwww.baidu.com
  返回格式 直接返回:http://t.cn/xxx
  请求方式 HTTP协议,支持GET/POST方法。
  接口备注 长网址缩短成新浪微博短网址,格式http://t.cn/xxx

PHP调用代码


$url = 'http://www.baidu.com';
$api_url = 'http://api.migourl.cn/tcn/api?key=用户KEY&url='.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://api.migourl.cn/tcn/api?key=(您的KEY)&url=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://api.migourl.cn'
path = '/tcn/api?key=(您的KEY)&'
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)