世界杯2018_世界杯北美区预选赛 - jmkxjj.com

如何生成t.cn的短链接?新浪短网址怎么生成的?

t.cn短链接、新浪短网址是什么? 短网址顾名思义就是一个很短的链接和网址,常用于将一个长连接缩短成一个短链接,方便利于推广。 t.cn短网址,可能很多朋友都已经不再陌生,特别是在微博、微信、朋友圈、QQ群、短信息等应用中十分普遍,短网址的前身是在新浪微博发微博时有时发很长的网址连接,但由于微博只限制140个字,所以微博就自动把您发的长网址给转换成短网址了。 t.cn短链接(t.cn/xxx)属于新浪微博旗下的短网址,原先是微博在使用。新浪短网址生成可以有效的避免链接过长,推广不便等因素 生成t.cn短连接后更有利于在微信推广和QQ群中推广 !目前过国内使用最多的短网址有三家。其中t.cn 属于新浪短链接,url.cn属于腾讯短链接,dwz.cn属于百度!今天我们要说的就是最好用的新浪短网址!

下面我们会主要介绍了PHP通过调用新浪短网址API生成t.cn格式短网址链接的方法,结合实例形式较为详细的分析了php调用新浪API生成t.cn短网址链接的具体操作步骤与相关注意事项,需要的朋友可以参考下!

API接口:1-http://maiyurl.cn/yunapi.html

2-http://mhdwz.cn/mahuaapi.html

3-http://dogdwz.cn/api.html

接口实例:http://maiyurl.cn/t/api?url_long=http://www.baidu.com

说明:

1、直接将api接口地址中 "http://www.baidu.com"换成需要缩短的网址,然后直接复制前往浏览器中打开即可。

2、请求方式:GET POST

3、参数:

①、appkey:appkey是调用接口的秘钥。用户的唯一标识,注册后在个人中心查询。

②、long_url:long_url是你需要缩短的长网址,需要进行utf-8编码!

调用代码:PHP调用演示:

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

$api_url = 'http://maiyurl.cn/weibourl?url_long=http://www.baidu.com;

$short_url = file_get_contents($api_url);

echo $short_url;JAVA调用演示:

public static void main(String path[]) throws Exception {

URL u=new URL("http://maiyurl.cn/weibourl?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://maiyurl.cn/'

path = 'weibourl?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)

2025-06-07 11:24:22
友情链接