Home >Backend Development >PHP Tutorial >WeChat General Interface Document_PHP Tutorial
The general interface uses HTTP requests to allow developers to directly interact with the WeChat server to implement functions such as media file upload and media file acquisition, and achieve the purpose of obtaining media files such as pictures, voices, and videos.
The access_token required to call the interface must be obtained through the credential acquisition interface.
Interface Description
Before using the common interface, you need to do the following two steps:
1. Have a WeChat public account and obtain the appid and appsecret (obtain it after applying for the custom menu function on the public platform, turning on the developer mode, and filling in the URL and Token)
2. Obtain access_token through the credential acquisition interface
Note:
access_token是第三方访问api资源的票据; access_token对应于公众号是全局唯一的票据,重复获取将导致上次获取的access_token失效。
Request instructions
http请求方式: GET https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
Parameter description
参数 | 是否必须 | 说明 |
---|---|---|
grant_type | 是 | 获取access_token填写client_credential |
appid | 是 | 第三方用户唯一凭证 |
secret | 是 | 第三方用户唯一凭证密钥,既appsecret |
Return instructions
Correct Json return result:
{"access_token":"ACCESS_TOKEN","expires_in":7200}
参数 | 说明 |
---|---|
access_token | 获取到的凭证 |
expires_in | 凭证有效时间,单位:秒 |
Incorrect Json return example:
{"errcode":40013,"errmsg":"invalid appid"}