# Interface with business systems
In order to facilitate developers to interface with the business system, developers can integrate it in the following ways:
- Currently only support the service provider business module and micro-housekeeper module deployed in the same service, in the service to call and forwarding and other behaviors to achieve the micro-housekeeper and service provider business system docking.
- Follow-up will support inter-service visits, such as the recent relevant needs can be privately sent to findThird Party Platform AssistantTo communicate.
Developers can integrate with the following functions:
- Micro butler support to receive WeChat official messages and forward to the service provider business system
- Microbutler supports receiving external requests and routing them to the service provider's business system
- Micromanager maintains the life cycle of third-party tokens and supports docking with service providers' business systems
- In addition, developers can read data from the micro-housekeeper database for docking with the business system.
If you have any problems with this function, go toWeChat Open Platform Service Provider ZoneFor feedback. You can also write privately.Third Party Platform AssistantNeed feedback and join the exclusive communication group, please note to join the third party platform management tool communication group.
# I. Service Development and Deployment
- How to implement the service provider business module and the micro-housekeeper module in the same service? You can refer to the operation steps below.
# 1.1 Modify the dockerfile
- To better understand how to modify dockerfile implementations to deploy the vendor business module and the micromanager module in the same service, developers can refer toThe official demoTo learn. This article is also based on the demo as a prototype.
1, to find the dockerfile service provider business services, the following is the official demo " Wxcloudrun-wxcomponent-flask "for example:
- Add the following information to the dockerfile and modify the startup command
FROM ccr.ccs.tencentyun.com/weixincloud/weixincloud_wxcomponent:latest as wxcomponent
COPY --from=wxcomponent /wxcloudrun-wxcomponent /wxcloudrun-wxcomponent
ENV GIN_MODE release
- Write start.sh startup script
- Notes
- Business service can not listen on port 80 and port 8081 (micro butler has listened on port 80, choose any other port listening to fill in the proxy configuration)
- The business cannot respond to the following api (already occupied by the micromanager)
/
/wxcallback/*
/wxcomponent/*
# 1.2. Redeployment services
The service provider business service modifies the dockerfile and reuploads the image to redeploy the service, which can be completed with reference to the following steps.
1, from the third party platform login WeChat cloud hosting (currently only support from the third party platform jump into the WeChat cloud hosting, can not directly visit the cloud hosting home page to log in). The specific path is: Third Party Platform - Details - Cloud Services - [Go to WeChat CloudRun]. After clicking, you will open the WeChat CloudRun Home Page with login status.
2, and then enter the cloud hosting console can be
3, enter the service list - enter service details - click "publish"
4, [optional] before the deployment, check whether there are the following four configurations in the service settings (the default will be, if not, you need to manually configure the deployment, otherwise the deployment will fail)
5, select the compressed package deployment service, at this time you can just repackage the image upload.
6, wait for a period of time, the deployment can be completed.
7, experience custom business
It can be accessed after deployment. withOfficial demowxcloudrun-wxcomponent-flask:For example, after you have completed deployment by following the development guidelines above, you can go to the proxy configuration.
Access after configuring port 8080 https://xxxxxx.ap-shanghai.run.tcloudbase.com/count。
# II. Message Forwarding Configuration
After the business service development and deployment is completed, the message forwarding configuration can be carried out in the micro-manager.
# 2.1 Forwarding Information Pushed to the Authorized Event URL
- The third-party platform account created by the service provider can receive the event information pushed to the service provider by the WeChat official through the "Authorized Event Configuration," some examples are as follows:
2、Notification of Change of Authorization
3、On behalf of the registration Mini Program events
- When the service provider business system needs to receive such event information, it can be distinguished by infoType, and it is strictly case-sensitive.
- To authorize the successful notification as an example, infoType need to fill authorized, fill Authorized is not effective.
- After the configuration is complete, the developer can perform connectivity testing
- You can turn off the transponder when no more forwarding is needed
<img src="https://res.wx.qq.com/op_res/Q74ZSHy4K_qqAi1Dm-jh5HNeQu3ANEzHt6tNijalnSWeBjgjEXsXm2IrwoeCoVj96jjcKKgyCX8fV7iaTcCM9w alt="" data-width="546" data-ratio="0.3076923076923077">
# 2.2 Forwarding information pushed to message and event URLs
- The third-party platform account created by the service provider can receive the official WeChat push through the "Message and Event Configuration" Official Account message template Or an event or message of the Mini Program (the service provider gets the Official Account message template Or Mini Program authorization can be replaced), some examples are as follows:
3、Distribution Single Delivery Status Update Notification Event
4、Official Account message template Ordinary message
- When the service provider business system needs to receive such event information, it can be distinguished by MsgType, and attention is strictly case-sensitive.
- If MsgType is Even, you need to fill in the Event name further, such as " weapp_audit_success"
# III. Proxy External Requests
- Micromanager supports proxy configuration, proxy After opening, the external request can be forwarded to the internal business service, so as to realize the docking of the micro-housekeeper with other business systems.
<img src="https://res.wx.qq.com/op_res/Q74ZSHy4K_qqAi1Dm-jh5MMPI6MnM5zdy2lntQMCUB8oVeJxEMrwE8zvLytMvOPcTpFgonyMaetmktFUkryCbg alt="" data-width="546" data-ratio="0.3076923076923077">
# IV. Data docking
- Micro-housekeeper database structure is as follows, developers can directly access the database for data reading.
<img src="https://res.wx.qq.com/op_res/6YcTlBe3g1tOR7udfg2V5_QDGLS22Juy_1dmrB3n4J_91LnqIICEixDAYRUGMRuTA1Bh5InZnq4LBbGRYvce5g alt="" data-width="546" data-ratio="0.3076923076923077">
# V. Unified management of tokens
- Micromanager 8081 port has token service, only listen to 127.0.0.1, no authentication, use http call can. Developers can obtain a "valid token" in the following ways, without having to deal with the expiration of the token.
- That is, the token obtained by the interface ensures that it is valid and does not expire.
- component_access_Token Get it by: http://127.0.0.1:8081/Inner/component-access-token
- authorizer_access_Token Get access as: http://127.0.0.1:8081/Inner/authorizer-access-token?appid=xxxx
Note: If the developer develops other services that are also refreshing tokens, it may result in a component that is obtained as above._access_token和authorizer_access_Token is not the latest.