There are often some long links in the process of public account development. if a QR code is generated at this time, it will lead to slow identification during the code scanning process. if it is stored in the database, the length of fields in the database must be set to a long value. Therefore, converting a persistent connection to a short link becomes more and more important. Business Scenario: there are often some long links in the process of public account development. if a QR code is generated at this time, the recognition will be slow during the code scanning process. if it is stored in the database, the length of fields in the database must be set to a long value. Therefore, converting a persistent connection to a short link becomes more and more important.
API instructions:
Mp.weixin.qq.com/wiki? T = resource/res_main & id = mp1443433600 & token = & lang = zh_CN
Interface call URL: https://api.weixin.qq.com/cgi-bin/shorturl? Access_token = ACCESS_TOKEN
Interface request method: post
Interface parameter data: json
Example of passing parameters through the API:
{"Action": "long2short", "long_url": "https: \/ss2.bdstatic.com \/kfoZeXSm1A5BphGlnYG \/icon \/7282.png "}
Interface returned data:
{"Errcode": 0, "errmsg": "OK", "short_url": "http: \// w.url.cn \/s \/An3qXvS "}
Convert to json:
{"Errcode": 0, "errmsg": "OK", "short_url": "http://w.url.cn/s/An3qXvS "}
The specific implementation code is as follows:
Okay. here is how to convert a long url to a short URL through the interface.
The above is the public account development: using the accesstoken to convert the persistent connection to the details of the short link. For more information, see other articles on php Chinese network!