Access_token Acquisition Development 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
|
1
2
3
4
5
6
7
8
9
10
11
12
13 |
<? Php
Define ("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 the content of the network request
// Echo $ res;
$ Result = json_decode ($ res, true); // receives a JSON string and converts it to a PHP variable.
$ Access_token = $ result ['Access _ token'];
Echo $ access_token;
Php>
|