The problem, some online reply by updating the developer password to get in (AppSecret), some spelling errors corrected in. I am here this problem is not a few years ago did not pay much attention at the right time, copy the code over the Internet to change to change the result of the problems encountered by the fact that a few basic concepts must be clear again, micro letter It is described in great understatement on this api documentation.
Micro-channel reference document: https: //developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html
Several important point list of what :( note marked red words)
First, the difference between the two scope authorized on the page description
1 to snsapi_base authorized scope for web-initiated, is used to get openid enter the user's page, and is silent authorized and automatically jump to the page callback. It is perceived by the user directly into the callback page (often a business page)
2, pages mandate to snsapi_userinfo as the scope initiated, is used to obtain the basic information of the user. However, this requires the user to manually authorize consent, and because the user agrees, so I do not need attention, you can get the basic information of the user after authorization.
3, user interface management class "Getting information about users Interface", is the message interaction or attention after the event push, you can retrieve information about users based on user generated OpenID users and the public number. After this interface, including other micro-channel interfaces, are the needs of the user (ie openid) public concern number to call succeeds.
Second, the difference between a page about access_token and authorization of ordinary access_token
1, micro-channel web authorization is achieved through OAuth2.0 mechanism, after the user authorization number to the public, the public can get to the interface call number certificate authorizing a specific web page (page authorize access_token), via the web can be authorized access_token after authorization interface calls, such as access to basic user information;
2, other micro-channel interfaces, common access_token call basis to support the "Get access_token" interface needs to get through.
So, if it is acquired for the two-dimensional code, you should use common access_token
So how do you get the general access_token it?
Interface call request as follows:
http request method: GET
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
Parameter Description
parameter | Do you have to | Explanation |
---|---|---|
grant_type | Yes | Get access_token fill client_credential |
appid | Yes | Third-party users only certificate |
secret | Yes | The only third-party user credential key that appsecret |
Returning to the description
Normally, micro-channel return data packet to the public number JSON following:
{"access_token":"ACCESS_TOKEN","expires_in":7200}
parameter | Explanation |
---|---|
access_token | To obtain credentials |
expires_in | Certificate valid time, unit: seconds |
In order not to get frequent, it is best to save up access_token, at the right time expired in the re-acquisition.