WeChat official account development: converts a persistent connection to a short link through an accesstoken

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.