Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat gadget tool HTTP call


May 20, 2021 WeChat Mini Program Development Document


Table of contents


The developer tool provides both the command line and the HTTP service interface for external calls, and developers can sign in, preview, upload, and more through the command line or HTTP request indication tool.

HTTP

The http service is automatically turned on after the tool is started, and the HTTP service port number is recorded in the user directory, which can be determined by checking the user directory, checking for port files in the user directory, and trying to connect.

Port number file location:

macOS : s/Library/Application Support/WeChat Web Developer Tool/Default/.ide

Windows: s/AppData/Local/WeChat Web Developer Tools/User Data/Default/.ide

1. Open the tool or specify the project

Interface definition:

URL: /open

HTTP Method: GET

URL parameters Required Description
projectpath Whether Open the item in the specified path. I f the project is open, the item is automatically refreshed. If the project is not created, the project is automatically created and opened

Example:

# 打开工具
http://127.0.0.1:端口号/open
# 打开/刷新项目
http://127.0.0.1:端口号/open?projectpath=项目全路径

Attention:

  • The project path must contain the correctly formatted project.config.json with appid and projectname fields.
  • The project path is subject to URL encode

2. Sign in

Interface definition:

URL:/login

HTTP Method: GET

URL parameters Required Description
format Whether Specify the login QR code return format, optional values are image, base64, terminal, default image. The picture format is png
qroutput Whether Specify the file path to write QR code data to the file. If specified, the QR code will be written to the file of the specified path, and if not specified, the QR code will be returned as the request body

Example:

# 登录,返回图片格式的二维码
http://127.0.0.1:端口号/login
# 登录,取 base64 格式二维码
http://127.0.0.1:端口号/login?format=base64
# 登录,取 base64 格式二维码,并写入 /Users/username/logincode.txt
http://127.0.0.1:端口号/login?format=base64&qroutput=%2FUsers%2Fusername%2Flogincode.txt

3. Preview

Interface definition:

URL:/preview

HTTP Method: GET

URL parameters Required Description
projectpath Is Preview the items in the specified path. I f the project is open, the item is automatically refreshed. If the project is not created, the project is automatically created and previewed
format Whether Specify the login QR code return format, optional values are image, base64, terminal, default image. The picture format is png
qroutput Whether Specify the file path to write QR code data to the file. If specified, the QR code will be written to the file of the specified path, and if not specified, the QR code will be returned as the request body

Example:

# 预览路径为 /Users/username/demo 的项目,返回图片格式的二维码
http://127.0.0.1:端口号/preview?projectpath=%2FUsers%2Fusername%2Fdemo
# 预览路径为 /Users/username/demo 的项目,返回 base64 格式的二维码
http://127.0.0.1:端口号/preview?projectpath=%2FUsers%2Fusername%2Fdemo&format=base64
# 预览路径为 /Users/username/demo 的项目,返回 base64 格式的二维码,并写入 /Users/username/logincode.txt
http://127.0.0.1:端口号/preview?projectpath=%2FUsers%2Fusername%2Fdemo&format=base64&qroutput=%2FUsers%2Fusername%2Flogincode.txt

4. Upload

Interface definition:

URL:/upload

HTTP Method: GET

URL parameters Required Description
projectpath Is Upload the items in the specified path
version Is Version number
desc Whether This uploaded version notes

Example:

# 上传路径为 /Users/username/demo 的项目,指定版本号为 v1.0.0
http://127.0.0.1:端口号/upload?projectpath=%2FUsers%2Fusername%2Fdemo&version=v1.0.0
# 上传路径为 /Users/username/demo 的项目,指定版本号为 v1.0.0,并带上备注
http://127.0.0.1:端口号/upload?projectpath=%2FUsers%2Fusername%2Fdemo&version=v1.0.0&desc=test

5. Automated testing

Interface definition:

URL:/test

HTTP Method: GET

URL parameters Required Description
projectpath Is Test the items in the specified path

Example:

# 提交路径为 /Users/username/demo 的项目进行测试
http://127.0.0.1:端口号/test?projectpath=%2FUsers%2Fusername%2Fdemo

Request a response

Normally, http has a status code of 200 and, in error 400, returns a JSON string in the following format:

{
  "code": 40000,
  "error": "原因"
}