This article introduces the concept and method of obtaining Access Token under the WeChat public platform.
1. Access Token
access_token is the globally unique ticket of the public account. The public account needs to use access_token when calling each interface. Under normal circumstances, access_token is valid for 7200 seconds. Repeated acquisition will cause the last access_token to become invalid.
The public account can use AppID and AppSecret to call this interface to obtain access_token. AppID and AppSecret can be obtained in development mode (you need to be a developer and your account has no abnormal status). Note that the https protocol must be used when calling all WeChat interfaces.
The unique credential key for third-party users, both appsecret
Return instructions
Under normal circumstances, WeChat will return the following JSON data packet to the public account:
{"access_token":"ACCESS_TOKEN","expires_in":7200}
Parameters
Description
##access_token
Obtained voucher
expires_in
Voucher validity time, unit: seconds
WeChat will return in case of error 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"}
2. AppId and AppSecret Use the WeChat background to find advanced functions - Development mode
After becoming a developer, you can see the appid and appsecert
If there is no url and Token, you can first use the following test from Fangbei Studio to passURL: http://discuz.comli.com/test.php
Token: weixin
3. Obtain Access TokenThe program is implemented as follows
Or use the official interface debugging tool, the address is:
Use the web debugging tool to debug the custom menu interface
Click to check the problem and get
In this way, you also get the access token
Attachment: Global return code description
Every time a public account calls an interface, it may get a correct or incorrect return code. Developers can debug the interface based on the return code information and troubleshoot errors.
The global return code description is as follows:
Return code
Description
-1
System busy
0
Request successful
40001
AppSecret error when obtaining access_token, or access_token is invalid
40002
Illegal credential type
40003
Illegal OpenID
40004
Illegal media file type
40005
Illegal file type
40006
Illegal file size
40007
Illegal media file id
##40008
Illegal message type
40009
Illegal image file size
##40010
Illegal voice file size
40011
Illegal video file size
##40012
Illegal thumbnail file size
40013
Illegal APPID
40014
Illegal access_token
##40015
Illegal menu type
40016
Number of illegal buttons
40017
Number of illegal buttons
40018
Illegal button name length
40019
Illegal button KEY length
40020
Illegal button URL length
40021
Illegal menu version number
40022
Number of illegal submenu levels
40023
Number of illegal submenu buttons
##40024
Illegal submenu button type
40025
Illegal submenu button name length
40026
Illegal submenu button KEY length
40027
Illegal submenu button URL length
40028
Illegal custom menu user
40029
Illegal oauth_code
40030
Illegal refresh_token
40031
Illegal openid list
40032
Illegal openid list length
40033
Illegal request characters, cannot contain \uxxxx format characters
{"errcode":45009,"errmsg":"api freq out of limit"}
各接口調(diào)用頻率限制如下:
接口
每日限額
獲取access_token
2000
自定義菜單創(chuàng)建
1000
自定義菜單查詢
10000
自定義菜單刪除
1000
創(chuàng)建分組
1000
獲取分組
1000
修改分組名
1000
移動用戶分組
100000
上傳多媒體文件
5000
下載多媒體文件
10000
發(fā)送客服消息
500000
獲取帶參數(shù)的二維碼
10000
獲取關注者列表
500
獲取用戶基本信息
5000000
獲取網(wǎng)頁授權access_token
2000000
刷新網(wǎng)頁授權access_token
2000000
網(wǎng)頁授權獲取用戶信息
2000000
更多微信公眾平臺開發(fā)-ACCESS TOKEN?相關文章請關注PHP中文網(wǎng)!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn