Development: distinguishes public platforms from open platforms, public account global creden, and webpage authorization creden,.
Although the company's own websites and projects developed for customers involve development, they have also written two articles on development, but they feel that they are easy to confuse some concepts in development, today, I browsed the public platform, Open Platform background, and related documents to figure out the following things. As for other things that have not yet been figured out, I will talk about them later.
1, public platform (https://mp.weixin.qq.com) and open platform (https://open.weixin.qq.com)
"The public platform is a platform for operators to provide information and services for users through the public account." After logging on to the public platform account, you can see that it has a good interactive interface. It can be used by company operators to publish messages and provide services.
The public platform Technical Documentation address is https://mp.weixin.qq.com/wiki. the interface domain name is:
Universal domain name (api.weixin.qq.com), which will be used to access the officially designated nearest access point;
Shanghai domain name (sh.api.weixin.qq.com), use this domain name to access the access point in Shanghai;
The Shenzhen domain name (sz.api.weixin.qq.com) will be used to access the access point in Shenzhen;
The Hong Kong Domain Name (hk.api.weixin.qq.com) uses this domain name to access the access point in Hong Kong.
Interface Description:"Developers can select the best access point based on their server deployment conditions (lower latency and higher stability ). In addition, other access points can be used for Disaster Tolerance. When a network link fails, you can select a backup access point for access ."
Refer to the "Getting Started Guide" and various chapters in the technical documents, and use the corresponding interfaces to develop programs to implement business functions such as publishing messages.
Open Platform: it is a platform provided for developers (programmers). Here you can set the public number (subscription number and service number) under your public platform) bind to your open platform account, so that you can perform more development based on the subscription number and service number. The subscriber interface permissions in the public account are limited. For example, the subscriber interface cannot obtain the webpage authorization permissions, and basic user information (such as openID and unionID) cannot be obtained through webpage authorization ).
In addition, more development scenarios may be like this: Company A has one subscription number to send information, and one service number to provide users with some services (such as querying materials ), there is also a pc-side website. When users use these subscription numbers, service numbers, and websites, how do developers of Company A identify users (identify the uniqueness of user identities ). The technical documentation "start development"-"access guide" of the public platform has been described as follows:
"Because developers often have the need to share user accounts across multiple platforms (mobile apps, websites, and public accounts) and unify the Account System, the open platform (open.weixin.qq.com) provides the UnionID mechanism. Developers can use OpenID to obtain basic user information. If a developer has multiple applications (mobile applications, website applications, and public accounts, the public account must be bound to an open platform account, you can identify the uniqueness of a user by obtaining the UnionID in the basic user information, as long as it is a mobile application, website application, or public account under the same open platform account, the user's UnionID is unique. In other words, UnionID is the same for different applications under the same open platform account. For more information, see Resource Center-mobile application development-Logon-Authorization Link Interface call guide-obtain user personal information (UnionID mechanism ."
2. The public account global credential (globally unique call credential) access_token and the webpage authorization access_token in Web Development
The two are not one thing, but they are easy to be confused when calling interfaces. In simple terms, webpage authorization tokens are used only when webpage logon is authorized, and are not used by other businesses, while global creden。 of public accounts are widely used.
How to obtain the global credential access_token of the Public Account: Use the AppID and AppSecret of the public account to call the interface for obtaining access_token. AppID and AppSecret can be obtained on the official website of the public platform-Development page, the interface call address and request method are as follows:
Https://api.weixin.qq.com/cgi-bin/token? Grant_type = client_credential & appid = APPID & secret = APPSECRET
Parameter description:
1 parameter description 2 3 parameter description 4 grant_type is used to obtain access_token enter client_credential5 appid is the third-party user (Public Account) Unique credential 6 secret is the third-party user (Public Account) Unique credential key, that is, appsecret
Description of returned data:
1 normally, the following JSON data packet is returned to the public: 2 {"access_token": "ACCESS_TOKEN", "expires_in ": 7200} 3 4 parameter description 5 the validity period of the 6 expires_in credential obtained by access_token. The unit is 7 seconds and 8 errors. The system will return error codes and other information, JSON data packet example (This example shows an invalid AppID error): 9 {"errcode": 40013, "errmsg": "invalid appid "}
One of the main business logic of web development is to provide users with the function of scanning code to log on to the website (or users can use their mobile phones to open the website to log on in the browser ), this involves authorizing a third party (Web developers) to obtain basic user information.
Webpage authorization access_token acquisition method: First let the user agree to authorization to obtain the code, and then exchange the code for webpage authorization access_token. For details, refer: public platform technical documentation-web development-webpage authorization Section or the article I wrote earlier: Processing login logic in callback functions for website login-description developed based on yii2, after obtaining the access_token, you can continue to call other interfaces for other operations.
Refer:
Public platform Technical Documentation
Open Platform Technical Documentation
End