Tencent short URL (url.cn short links) generates interface (API) Recommended

A brief description

Tencent short URL (url.cn short links) to generate a short URL api interface is a Tencent official publicly generation interface, a lengthy short link can be shortened to link up to 10 characters.

Scenarios

Tencent scenarios short URL is very broad, such as SMS marketing, email marketing, marketing micro letter, QQ marketing, media self-promotion, channel promotion, will be used short URL. The reason is that short URL can reduce promotion costs, user memory costs, improve user click-through rate; promotion also avoid keywords in a particular scene, was blocked to prevent the domain name, hide the real address.

Interface Tencent Short URL

Formats: http://qturl.cn/urldwz/api.html?url=http://www.baidu.com

Format two: http://www.ldurl.cn/short-urlcn?link=http://www.baidu.com

Three formats: http://www.urlhx.cn/weixin-url/api?url_long=http://www.baidu.com

Schemes for Fourth: http://www.66kuaitu.cn/urlcn.php?url=http://www.baidu.com

格式五:http://http://kndwz.com/url-api.php?link=http://www.baidu.com

Document Interface

1, request method

  • POST 

2, return format

  • Direct return "https://url.cn/xxxx"

3, use

① online use

Simply "http://www.baidu.com" need to shorten long URLs into (with the http (s): //), then copy the whole string browser to open links go to generate.

② request interface

Generating the server request interface is provided, each time a request to return a result, the following example related requests.

4, sample request

PHP:

1 $url = 'http://www.baidu.com';
2 $api_url = 'http://qturl.cn/urldwz/api.html?url=http://www.baidu.com;
3 $short_url = file_get_contents($api_url);
4 echo $short_url;

 

Java:

 1 public static void main(String path[]) throws Exception {
 2 URL u = new URL("http://qturl.cn/urldwz/api.html?url=http://www.baidu.com");
 3 InputStream in = u.openStream();
 4 ByteArrayOutputStream out = new ByteArrayOutputStream();
 5 try {
 6 byte buf[] = new byte[1024];
 7 int read = 0;
 8 while ((read = in .read(buf)) > 0) {
 9 out.write(buf, 0, read);
10 }
11 } finally {
12 if ( in != null) {
13 in .close();
14 }
15 }
16 byte b[] = out.toByteArray();
17 System.out.println(new String(b, "utf-8"));
18 }

 

Python:

 1 import urllib, urllib2, sys
 2 host = 'http://qturl.cn'
 3 path = '/urldwz/api.html'
 4 method = 'GET'
 5 querys = 'url_long=http%3A%2F%2Fwww.baidu.com'
 6 bodys = {}
 7 url = host + path + '?' + querys
 8 request = urllib2.Request(url)
 9 response = urllib2.urlopen(request)
10 content = response.read()
11 if (content):
12 print(content)

 

 

Additional information:

1, when the request interface, if generate a short URL, find the original URL parameter is missing, you need to link to the original processing urlencode do, and then go to generate.

2, the long URL request interface must be to http (s): // at the beginning.

3, interface request frequency recommended not too fast, normal 1 / s.

common problem:

1, after long URLs into why the argument is lost?

A: Because not do urlencode process, resulting in some special characters not recognized. The encoder then needs to request interface url.

2, request interface Why did not return a result?

A: Sometimes there is a delay data interface to return, it will lead to time-out did not return. Or because the original link was closed.

3, valid for generating the short URL is how long? There is no limit visits?

A: Share short URL generated interface is valid, the official version of the interface to generate short URLs are permanently valid.

4, there is no short URL access restrictions?

A: This interface is based on the official website interfaces developed, no visits limited, and ease of use.

Reprinted from the original: http://qturl.cn/blog-urlcn.html

Guess you like

Origin www.cnblogs.com/hhzs/p/12321416.html