In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The purpose of this article is to share with you the content of the sample analysis of ACCESS TOKEN developed by Wechat public platform. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Access Token
Access_token is the global unique ticket of the official account, which needs to use access_token when calling each interface. Under normal circumstances, the access_token is valid for 7200 seconds. Repeated acquisition will invalidate the last acquired access_token.
The official account can use AppID and AppSecret to call this API to obtain access_token. AppID and AppSecret are available in the development mode (you need to be a developer and the account has no abnormal status). Note that https protocol is required when calling all Wechat APIs.
API call request description
Http request method: GET https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
Parameter description
Whether the parameter must indicate whether grant_type is obtained by access_token. Fill in that client_credentialappid is the only credential key for third-party users. Secret is the unique credential key for third-party users, that is, appsecret.
Return description
Normally, Wechat will return the following JSON packets to the official account:
{"access_token": "ACCESS_TOKEN", "expires_in": 7200} parameters indicate the validity period of the expires_in credential obtained by access_token (in seconds)
Wechat will return information such as error code when an error occurs. An example of JSON packet is as follows (this example is an invalid AppID error):
{"errcode": 40013, "errmsg": "invalid appid"} II, AppId and AppSecret
Use the Wechat backstage to find advanced functions-development mode
After becoming a developer, you can see appid and appsecert
If you don't have url and Token, you can pass the following test in Fangbi Studio first.
URL: http://discuz.comli.com/test.php
Token: weixin
3. Obtain Access Token
The program is implemented as follows
$appid = ""; $appsecret = ""; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";$ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec ($ch); curl_close ($ch) $jsoninfo = json_decode ($output, true); $access_token = $jsoninfo ["access_token"]
You can also splice the address directly in the browser address bar. After execution, you can get the following data
{"access_token": "N2L7KXa084WvelONYjkJ_traBMCCvy_UKmpUUzlrQ0EA2yNp3Iz6eSUrRG0bhaR_viswd50vDuPkY5nG43d1gbm-olT2KRMxOsVE08RfeD9lvK9lMguNG9kpIkKGZEjIf8Jv2m9fFhf8bnNa-yQH3g", "expires_in": 7200}
The parameters are described as follows
Parameters.
Description
Access_token
Obtained vouchers
Expires_in
Credential validity time (in seconds)
Or use the official interface debugging tool at the following address:
Use the web page debugging tool to debug the custom menu interface
Click to check the problem, get
This also got the access token.
Attached: global return code description
Each time the official account calls the API, it may get a correct or incorrect return code. Developers can debug the interface according to the error code information and troubleshoot errors.
The global error code is described as follows:
The return code indicates that-1 AppSecret error occurred when the system was busy 0 and the request was successful 40001 to get access_token. Or access_token invalid 40002 illegal credential type 40003 illegal OpenID40004 illegal media file type 40005 illegal file type 40006 illegal file size 40007 illegal media file size 40007 illegal media file id40008 illegal message type 40009 illegal picture file size 40010 illegal voice file size 40011 illegal video file size 40012 illegal thumbnail file size 40013 illegal APPID40014 illegal Legal access_token40015 illegal menu type 40016 illegal button number 40017 illegal button name length 40019 illegal button length 40020 illegal button length 40020 illegal URL length 40021 illegal menu version number 40022 illegal submenu number 40023 illegal submenu button number 40024 illegal submenu button type 40025 illegal submenu button name long Degree 40026 illegal submenu button KEY length 40027 illegal submenu button URL length 40028 illegal custom menu using user 40029 illegal oauth_code40030 illegal refresh_token40031 illegal openid list 40032 illegal openid list length 40033 illegal request character Cannot contain characters 40035 illegal parameter 40038 illegal request format 40039 illegal URL length 40050 illegal packet id40051 packet name illegal 41001 missing access_token parameter 41002 missing appid parameter 41003 missing refresh_token parameter 41004 missing secret parameter 41005 missing multimedia file data 41006 missing media_id parameter 41007 missing submenu data 41008 missing oauth code41009 missing openid42001access_token timeout 42002refresh _ token super 42003oauth_code timeout 43001 requires GET request 43002 requires POST request 43003 requires HTTPS request 43004 requires recipient attention 43005 requires friend relationship 44001 empty multimedia file empty 44002POST packet empty 44004 text message content empty 45001multimedia file size exceeds limit 45002 message content exceeds limit 45003title field exceeds limit 45004description field exceeds limit 45005link field exceeds limit 45006 Picture Link field exceeds limit 45007 Voice playback time exceeds limit 45008 Teletext message exceeds limit 45009 API calls exceed limit 45010 create menus exceed limit 45015 reply time exceeds limit 45016 system packet It is not allowed to modify 45017 packet name too long 45018 packet number exceeds the upper limit 46001 does not exist media data 46002 does not exist menu data 46003 does not exist menu data 46004 does not exist user 47001 parsing JSON/XML content error 48001api function unauthorized 50001user unauthorized api: interface frequency limit description
The official account invokes the interface is not unlimited. To prevent Wechat server load exception caused by program errors of official account, by default, each official account calling API cannot exceed a certain limit. When a certain limit is exceeded, the following error return code will be received for calling the corresponding API:
{"errcode": 45009, "errmsg": "api freq out of limit"}
The calling frequency of each API is limited as follows:
API Daily quota acquisition access_token2000 Custom menu creation 1000 Custom menu query 10000 Custom menu Delete 1000 create packet 1000 get packet 1000 modify Group name 1000 Mobile user Group 100000 upload Multimedia File 5000 download Multimedia File 10 000 send customer service message 500000 get QR code with parameters get follower list 500 get user basic information 5000000 get web authorization access_token2000000 refresh net Page authorization access_token2000000 page authorization to obtain user information 2000000 Thank you for your reading! This is the end of the article on "sample Analysis of ACCESS TOKEN developed by Wechat Public platform". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.