首页 > 应用开发 > IT综合 > 新浪短链接生成 新浪短链接转化器推荐
简要描述:
新浪短网址生成平台:http://maiyurl.cn
新浪链接址生成平台:http://www.sinadwz.cn
t.cn短网址生成平台:http://www.qqdwz.cn
新浪很久之前提供了长链接转为短链接的API,可以把长链接转为t.cn/xxx这种格式的短链接。但是在前些时候,新浪由于政策上的调整,将之前的接口关闭了! 很多小伙伴都遇到过新浪短链接的困惑吧,一些朋友看过网上零散的新浪短链接的处理方法,并没有完完全全明白新浪短链接是如何解决的,今天大家只要看了小编在上面推荐的几个平台,只需要按照我们教程操作即可轻松使用了!
API接口请求方式:
GET
参数:
|
参数名 |
必选 |
类型 |
说明 |
|---|---|---|---|
|
url |
是 |
string |
需要缩短的链接 |
请求示例
http://maiyurl.cn/tengxurl?url_long=http://www.baidu.com
返回示例
{"short_url": "https://url.cn/54R8NCd","long_url": "https://www.baidu.com/s?ie=UTF-8&wd=api"}
返回参数说明
|
参数名 |
类型 |
说明 |
|---|---|---|
|
short_url |
string |
缩短后的链接 |
|
long_url |
string |
原长链接 |
1、PHP请求示例:
$url = 'http://; $api_url = ' http://maiyurl.cn/weixin/short?link=http://www.baidu.com; $short_url = file_get_contents($api_url); echo $short_url;
2、Java请求示例:
public static void main(String path[]) throws Exception {
URL u = new URL(" http://maiyurl.cn/weixin/short?link=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"));
}
3、Python请求示例:
import urllib, urllib2, sys
host = ' http://maiyurl.cn'
path = '/weixin/short'
method = 'GET'
querys = 'link=http%3A%2F%2F
bodys = {}
url = host + path + '?' + querys
request = urllib2.Request(url)
response = urllib2.urlopen(request)
content = response.read()
if (content):
print(content)
备注
更多短网址请访问 短链接API接口官网
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69973248/viewspace-2689560/ ,如需转载,请注明出处,否则将追究法律责任。