This article mainly introduces the implementation method of PHP long URL and short URL. Friends who need it can refer to it
As the name suggests, a long link is a very long link; a short link is a very short link . Long links can generate short links, and short links come from long links.
What are long links and short links
As the name suggests, a long link is a very long link; a short link is a very short link . Long links can generate short links, and short links come from long links.
Why should we use long links and short links?
is more beautiful. We can compare long links and short links. Obviously we can see Outgoing short links are shorter and more beautiful than outgoing links.
Security, long links may carry some parameters, such as http://xxx.xxx.xxx?id=1¶m1=san, we can easily see that the url uses get method, and you can also see which parameters are requested. However, we can only access the short link http://t.cn/RNGQRUJ and cannot easily check what parameters and other conditions are carried there.
Sample code download address: Link: https://pan.baidu.com/s/1kVh4FQ3 Password: 4r8p
##Usage scenario
Sharing of Weibo contentThe link contained in the text messageWeChat sharing linkImplementation method
According to Baidu Encyclopedia’s explanation, the conversion of long links into short links mainly uses md5 encryption to achieve the conversion.Code implementation
Create a curl tool function1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 5 6 |
|
How to implement PHP to call the Yunpian network interface to send text messages
PHP
Parameter description of CURL CURLOPT
The above is the detailed content of How to implement long and short URLs in PHP. For more information, please follow other related articles on the PHP Chinese website!