# Asynchronous Call Service Platform Interface Dxplaination
Some of the services on the service platform are time-consuming and provide services in the form of asynchronous APIs.
# Server-side usage
- Developers can accessinvokeServiceInterface get request_id 初始值 Then callretrieveInterface to get the data after asynchronous processing.
- The basic usage process is as follows:
- In addition to active inquiry, it also provides the ability to push messages. For details, please see the instructions issued by the document.
Be careful
1、 For the asynchronous API, after invoking invokeService API must be filled inasync:true
Parameters.
2, retrieve entry parameters need to fill in the invokeSevice request triggered asynchronous request return request_Id, the API will also return the request for this request_Id, and the request of the input parameter_Id is different.
3, asynchronous request to get back results have validity, the longest does not exceed 24 hours, different API validity may be different, need to refer to specific API documentation.
4, asynchronous API only trigger request deduction, polling request is not deducted. If the service provider does not return a result within a timeout, or returns an error, the request fee will be refunded to the developer.
# Server-side messaging push
If the developer has enabled and correctly configured push messaging in development settings, and the developer uses an API that provides push messaging capabilities, the developer will receive an event push containing the result of the request after asynchronous request processing has completed.
# Message Push Format:
Field Name | type | Required | Default value | Introductions |
---|---|---|---|---|
ToUserName | string | yes | Small Program Original ID | |
FromUserName | string | yes | The OpenID of the WeChat team under the Mini Program | |
CreateTime | number | yes | Push time | |
MsgType | string | yes | Event type, fixed to "event" | |
Event | string | yes | Event type, fixed to " servicemarket_async_api_result" | |
Api | string | yes | API name | |
Data | string | yes | API Result | |
RequestID | string | yes | RequestID that triggers the request | |
Service | string | yes | Service Provider ServiceID |
Example:
{
"ToUserName": "gh_3fe144c9bded",
"FromUserName": "oG1Ug5fdiwJi2GZ1BzTHo3JS3dQo",
"CreateTime": 1603439487,
"MsgType": "event",
"Event": servicemarket_async_api_result",
"Api": "api_name",
"Data": "{"result":"hello world"}",
"RequestID": "MLymLNve4FwfMA4YlZ4yiYQKJzqTksjLYZpP2OOoWrPiEe6rMkj5JymcJq6tL7p3LKk",
"Service": "wx10427c80e0ae4c1d"
}
Be careful:
1, whether it is a Mini Program side trigger or a server-side trigger, as long as the two conditions of correctly enabling the message push and the API support the message push are met, the server will receive the processing result event push.
2, if the Mini Program authorizes the service market permission set to a third-party platform, the event will be pushed to the third-party platform and will not be pushed to the developer's background.