WeChat public platform development: General Interface Description

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.