The "Common Interface (CommonAPIs)" mentioned here is a required verification feature for using a series of advanced functions of a public account (used in development mode ).
I. Basic description
The "Common Interface (CommonAPIs)" mentioned here is a required verification feature for using a series of advanced functions of a public account (used in development mode ).
We send a request to the common interface using the unique credential in the background to obtain the access token, and then use the access token to use the advanced features that require identity verification, for example, custom menus, user information retrieval, single message sending, and group message sending.
Currently, all service numbers and authenticated subscription numbers, you can find the AppId and AppSecret strings in the "developer creden" column of "functions"> "advanced functions"> "development mode" in the public account background, these two strings are the basis for obtaining the AccessToken, so they must be kept strictly confidential. if any leakage is found, or out of security policy, appSecret should be randomly generated using the "reset" button on the edge (note that the AppId will not change) and the corresponding parameters in the program should be modified at the same time.
File description:
AccessTokenContainer. cs-an AccessToken container (help automatically update AccessToken because each AccessToken has a validity period)
CommonApi. cs-provides a general method to obtain the AccessToken
CommonApi. Menu. cs-custom Menu all interfaces
CommonJsonSend. cs-encapsulate and process the returned types of common interfaces
For the detailed method and description of the above class, you can see the source code comment: https://github.com/JeffreySu/WeiXinMPSDK/tree/master/Senparc.Weixin.MP/Senparc.Weixin.MP/CommonAPIs
With AccessTokenContainer, we can directly obtain the AccessToken as follows:
If (! AccessTokenContainer. checkRegistered (appId) // check whether {AccessTokenContainer has been registered. register (appId, appSecret); // if not registered, Register.} var result = AccessTokenContainer. getAccessTokenResult (appId); // Obtain the AccessToken result
Of course, it can also be easier to implement in one step:
var result = AccessTokenContainer.TryGetAccessToken(appId, appSecret);
The obtained result has two attributes: access_token and expires_in. the AccessToken string and Expiration Time (in seconds) are respectively stored. if you use AccessTokenContainer. tryGetAccessToken () method, expires_in can be ignored completely. If it expires, the system will automatically obtain it again.
For more public platform development: For more information about common interfaces, see PHP!