WeChat access_token acquisition development example, access_token example _ PHP Tutorial

Source: Internet
Author: User
Access_token acquisition development example, access_token example. Access_token acquisition development example. access_token example overview access_token is the globally unique ticket of the public account. access_token is required when the public account calls each interface. Developer needs access_token to obtain the development example, access_token example

Overview

Access_token is the globally unique ticket of the public account. access_token is required when the public account calls each interface. Developers need to properly store them. The storage of access_token must contain at least 512 characters. The validity period of access_token is currently 2 hours. you need to refresh it regularly. repeated access_token acquisition will invalidate the last access_token.

Access_token acquisition

<? Phpdefine ("APPID", "your appid"); define ("APPSECRET", "your appsecret"); $ token_access_url = "https://api.weixin.qq.com/cgi-bin/token? Grant_type = client_credential & appid = ". APPID. "& secret = ". APPSECRET; $ res = file_get_contents ($ token_access_url); // get the file content or obtain the content of the network request // echo $ res; $ result = json_decode ($ res, true ); // accept a JSON string and convert it to the PHP variable $ access_token = $ result ['Access _ token']; echo $ access_token; php>

The above is all the content of this article. I hope you will like it.

Token Overview access_token is the globally unique ticket of the public account. access_token is required when the public account calls each interface. Developers need...

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.