推荐几个最新的腾讯URL短网址以及新浪TCN短链接的API接口

新浪微博好久以前提供了长连接转为短连接的API,能够把长连接转为t.cn/xxx这种格式的短连接。可是在今年9月的时候,新浪因为政策上的调整,将以前的接口关闭了!api

不少小伙伴都遇到过新浪短连接的困惑吧,一些朋友看过网上零散的新浪短连接的处理方法,并无完彻底全明白新浪短连接是如何解决的,今天小编准备了简单的解决办法,只须要按照咱们教程操做便可,因此今天我就给你们推荐几个咱们如今正在使用的新浪短连接API接口,但愿能够帮助到你们!!!url

新浪短网址API接口

接口地址:http://www.wx-dwz.cn/tcnurl?u...://www.baidu.comspa

接口地址:http://mhdwz.cn/mhsina?url=http://www.baidu.comcode

接口地址:http://maiyurl.cn/weibourl?url=http://www.baidu.com blog

接口地址:http://www.qqdwz.cn/tcn/api?url=http://www.baidu.com教程

腾讯短网址API接口

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

接口地址:http://maiyurl.cn/tengxurl?url_long=http://www.baidu.comutf-8

接口地址:http://www.sina-url.cn/urlcn/api?url_long=http://www.baidu.comrem

短网址API说明

将以上短网址api接口的"http://www.baidu.com"部分替换成您所须要的长连接便可生成对应的新浪短网址!文档

新浪短网址接口文档

PHP调用代码:

$url = 'http://www.baidu.com';
$api\_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%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 = ''     path = ''     method = 'GET'     querys = '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)

相关文章
相关标签/搜索