Long link to short link interface
Long link to short link interface
# #Convert a long link into a short link.
Main usage scenarios: The original link used by developers to generate QR codes (products, payment QR codes, etc.) is too long, which leads to a decrease in scanning speed and success rate. The original long link is converted through this interface. Regeneration of short links into QR codes will greatly improve the speed and success rate of scanning codes.Interface call request description
Developers can obtain basic user information through OpenID. Please use https protocol. http request method: POSThttps://api.weixin.qq.com/cgi-bin/shorturl?access_token=ACCESS_TOKEN
Parameter Description
Parameter | Is it necessary | Description |
---|---|---|
access_token | is | calling interface credentials |
action | is | Fill in here long2short, represents long link to short link |
long_url | is the long link that | needs to be converted, supports http://, https:// , weixin://wxpay format url |
Call example
curl -d "{\"action\":\"long2short\",\"long_url\":\"http://wap .koudaitong.com/v2/showcase/goods?alias=128wi9shh&spm=h56083&redirect_count=1\"}" "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=ACCESS_TOKEN"
Return instructions
Under normal circumstances, WeChat will return the following JSON data packet to the official account:
{"errcode":0,"errmsg":"ok ","short_url":"http:\/\/w.url.cn\/s\/AvCo6Ih"}
Parameter description
Parameter | Description |
---|---|
errcode | error code. |
errmsg | Error message. |
short_url | Short link. |
When an error occurs, WeChat will return error code and other information. The JSON data packet example is as follows (this example is an invalid AppID error):
{" errcode":40013,"errmsg":"invalid appid"}