May 18, 2021 WeChat Mini Program Development Document
Each WeChat program needs to set up a communication domain name in advance, the small program can communicate with the designated domain name and network. Includes normal HTTPS requests (wx.request), WebSocket communications (wx.connectSocket), upload files (wx.uploadFile), and download files (wx.downloadFile).
List of network APIs:
Api | Description |
---|---|
wx.request | Make a network request |
wx.uploadFile | Upload the file |
wx.downloadFile | Download the file |
wx.connectSocket | Create a WebSocket connection |
wx.onSocketOpen | Listen to WebSocket open |
wx.onSocketError | Listen for WebSocket errors |
wx.sendSocketMessage | Send a WebSocket message |
wx.onSocketMessage | Accept the WebSocket message |
wx.closeSocket | Turn off the WebSocket connection |
wx.onSocketClose | Listen to WebSocket off |
tip
referer requested by the network is not set and is fixed to https://servicewechat.com/'appid'/'version'/page-frame.html where the appid is the
{appid}
of the applet, the
{version}
is the version number of the applet, and the version number is 0 for the development version.
tip
When a small program enters a background run (non-top chat), the error message "failinterrupted" is called if the network request within 5s does not end;