Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

Overview

This PR adds all missing domain configuration APIs for WeChat mini-programs and third-party platforms as requested in issue #3739. The WeChat Open Platform provides domain configuration APIs at two levels: mini-program level and third-party platform level. This implementation completes support for all missing APIs.

APIs Added

Mini-Program Domain APIs (WxOpenMaService)

1. Fast Configure Mini-Program Server Domains (modifyDomainDirectly)

Implements the fast version of server domain configuration:

  • API URL: https://api.weixin.qq.com/wxa/modify_domain_directly
  • Documentation: modify_domain_directly
  • Actions supported: add, delete, set, get
  • Domain types: request, websocket, upload, download, UDP, TCP
WxOpenMaDomainResult result = wxOpenMaService.modifyDomainDirectly(
    "set", 
    Arrays.asList("https://api.example.com"),
    Arrays.asList("wss://socket.example.com"),
    Arrays.asList("https://upload.example.com"),
    Arrays.asList("https://download.example.com"),
    null, null
);

2. Fast Configure Mini-Program Business Domains (setWebViewDomainDirectly)

Implements the fast version of business domain configuration:

  • API URL: https://api.weixin.qq.com/wxa/setwebviewdomain_directly
  • Documentation: setwebviewdomain_directly
  • Actions supported: add, delete, set, get
  • Two variants provided:
    • setWebViewDomainDirectly() - returns raw String response
    • setWebViewDomainDirectlyInfo() - returns parsed WxOpenMaWebDomainResult object
// Option 1: Get raw response
String response = wxOpenMaService.setWebViewDomainDirectly(
    "add",
    Arrays.asList("https://business.example.com")
);

// Option 2: Get parsed result
WxOpenMaWebDomainResult result = wxOpenMaService.setWebViewDomainDirectlyInfo(
    "add",
    Arrays.asList("https://business.example.com")
);

Third-Party Platform Domain APIs (WxOpenComponentService)

3. Configure Third-Party Platform Server Domains (modifyWxaServerDomain)

Configures server domains for the third-party platform itself:

  • API URL: https://api.weixin.qq.com/cgi-bin/component/modify_wxa_server_domain
  • Documentation: modify_wxa_server_domain
  • Actions supported: add, delete, set, get
  • Domain types: request, websocket, upload, download, UDP, TCP
WxOpenMaDomainResult result = wxOpenComponentService.modifyWxaServerDomain(
    "set",
    Arrays.asList("https://platform-api.example.com"),
    Arrays.asList("wss://platform-socket.example.com"),
    Arrays.asList("https://platform-upload.example.com"),
    Arrays.asList("https://platform-download.example.com"),
    null, null
);

4. Get Third-Party Platform Domain Confirmation File (getDomainConfirmFile)

Retrieves the domain verification file for third-party platform:

  • API URL: https://api.weixin.qq.com/cgi-bin/component/get_domain_confirmfile
  • Documentation: get_domain_confirmfile
  • Returns: File name and content for domain verification
WxOpenMaDomainConfirmFileResult result = wxOpenComponentService.getDomainConfirmFile();

5. Configure Third-Party Platform Business Domains (modifyWxaJumpDomain)

Configures business domains for the third-party platform:

  • API URL: https://api.weixin.qq.com/cgi-bin/component/modify_wxa_jump_domain
  • Documentation: modify_wxa_jump_domain
  • Actions supported: add, delete, set, get
  • Two variants provided:
    • modifyWxaJumpDomain() - returns raw String response
    • modifyWxaJumpDomainInfo() - returns parsed WxOpenMaWebDomainResult object
// Option 1: Get raw response
String response = wxOpenComponentService.modifyWxaJumpDomain(
    "add",
    Arrays.asList("https://platform-business.example.com")
);

// Option 2: Get parsed result
WxOpenMaWebDomainResult result = wxOpenComponentService.modifyWxaJumpDomainInfo(
    "add",
    Arrays.asList("https://platform-business.example.com")
);

Note on Existing API

The API get_webviewdomain_confirmfile for mini-programs was already implemented as getWebviewDomainConfirmFile() in the codebase, so no additional implementation was needed for it.

Implementation Details

  • All implementations follow existing code patterns for consistency
  • Uses the same request/response structure as existing domain APIs
  • Properly handles all action types (add, delete, set, get)
  • Includes comprehensive Javadoc documentation with links to official WeChat documentation
  • Returns appropriate result types for easy integration

Testing

  • ✅ Maven compile: SUCCESS
  • ✅ Maven package: SUCCESS
  • ✅ Checkstyle validation: PASSED
  • ✅ Follows Google Java Style Guide

Note: Integration tests require valid WeChat Open Platform credentials and are disabled by default.

Files Changed

  • weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java - Added mini-program interface methods and API constants
  • weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java - Added mini-program implementations
  • weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java - Added third-party platform interface methods and API constants
  • weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java - Added third-party platform implementations

Total: 200 lines added across 4 files

Fixes #3739

Original prompt

This section details on the original issue you should resolve

<issue_title>缺少快速配置小程序业务域名/快速配置小程序服务器域名/获取业务域名校验文件</issue_title>
<issue_description># 缺少快速配置小程序业务域名/快速配置小程序服务器域名/获取业务域名校验文件这几个接口的实现。目前只有

官方文档地址

接口代号 接口名称 接口地址
接口A 配置小程序服务器域名 modify_domain
接口B 配置小程序业务域名 setwebviewdomain
接口F 设置第三方平台服务器域名 modify_wxa_server_domain
接口G 获取第三方平台业务域名校验文件 get_domain_confirmfile
接口H 设置第三方平台业务域名 modify_wxa_jump_domain

缺少
接口代号 接口名称 接口地址
接口C 快速设置小程序服务器域名 modify_domain_directly
接口D 获取业务域名校验文件 get_webviewdomain_confirmfile
接口E 快速配置小程序业务域名 setwebviewdomain_directly
这里两种方式的逻辑不一样</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #3739


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add fast configuration APIs for mini program domains Add missing fast domain configuration APIs for mini-programs Oct 23, 2025
Copilot finished work on behalf of binarywang October 23, 2025 02:25
Copilot AI requested a review from binarywang October 23, 2025 02:25
@binarywang binarywang marked this pull request as ready for review October 23, 2025 02:47
@binarywang
Copy link
Owner

@copilot 还缺少很多接口,目前只增加了快速配置小程序服务器域名相关的接口

Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot 还缺少很多接口,目前只增加了快速配置小程序服务器域名相关的接口

已补充完整。新增了第三方平台域名配置相关的三个接口 (Interface F, G, H):

  1. modifyWxaServerDomain() - 设置第三方平台服务器域名
  2. getDomainConfirmFile() - 获取第三方平台业务域名校验文件
  3. modifyWxaJumpDomain() / modifyWxaJumpDomainInfo() - 设置第三方平台业务域名

所有原始 issue #3739 中提到的接口 (C, D, E, F, G, H) 现已全部实现完成。

Commit: df872db

Copilot AI changed the title Add missing fast domain configuration APIs for mini-programs Add missing domain configuration APIs for mini-programs and third-party platform Oct 23, 2025
Copilot finished work on behalf of binarywang October 23, 2025 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

缺少快速配置小程序业务域名/快速配置小程序服务器域名/获取业务域名校验文件

2 participants