# 设置服务器域名
授权给第三方的小程序,其服务器域名只可以为在第三方平台账号中配置的小程序服务器域名,当小程序通过第三方平台发布代码上线后,小程序原先自己配置的服务器域名将被删除,只保留第三方平台的域名,所以第三方平台在代替小程序发布代码之前,需要调用接口为小程序添加第三方平台自身的域名。 使用过程中如遇到问题,可在开放平台服务商专区发帖交流。
注意:
1、需要先将域名登记到第三方平台的小程序服务器域名中,才可以调用接口进行配置。
2、Request域名、Socket域名、Uploadfile域名、Download域名、Udp域名、tcp的设置数量均最大支持200个
3、每月可提交修改申请50次
4、可以配置端口,如 https://myserver.com:8080,但是配置后只能向 https://myserver.com:8080 发起请求。如果向 https://myserver.com、https://myserver.com:9091 等 URL 请求则会失败。
5、域名必须经过 ICP 备案
6、不支持填写 ip 地址,要用域名
7、api.weixin.qq.com 不能被配置为服务器域名
# 请求地址
POST https://api.weixin.qq.com/wxa/modify_domain?access_token=ACCESS_TOKEN
# 请求参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
access_token | string | 是 | 第三方平台接口调用令牌authorizer_access_token |
action | string | 是 | 操作类型 |
requestdomain | string array | 是 | request 合法域名;当 action 是 get 时不需要此字段 |
wsrequestdomain | string array | 是 | socket 合法域名;当 action 是 get 时不需要此字段 |
uploaddomain | string array | 是 | uploadFile 合法域名;当 action 是 get 时不需要此字段 |
downloaddomain | string array | 是 | downloadFile 合法域名;当 action 是 get 时不需要此字段 |
udpdomain | string array | 是 | udp 合法域名;当 action 是 get 时不需要此字段 |
tcpdomain | string array | 是 | tcp 合法域名;当 action 是 get 时不需要此字段 |
# action 可选值
可选值 | 说明 |
---|---|
add | 添加 |
delete | 删除 |
set | 覆盖 |
get | 获取 |
POST 数据示例:
{
"action": "add",
"requestdomain": ["https://www.qq.com", "https://www.qq.com"],
"wsrequestdomain": ["wss://www.qq.com", "wss://www.qq.com"],
"uploaddomain": ["https://www.qq.com", "https://www.qq.com"],
"downloaddomain": ["https://www.qq.com", "https://www.qq.com"],
"udpdomain": ["udp://melody.weixin.melody.com"],
"tcpdomain": ["tcp://melody.weixin.melody.com"]
}
# 返回参数说明
参数 | 类型 | 说明 |
---|---|---|
errcode | number | 返回码 |
errmsg | string | 错误信息 |
requestdomain | string array | request 合法域名 |
wsrequestdomain | string array | socket 合法域名 |
uploaddomain | string array | uploadFile 合法域名 |
downloaddomain | string array | downloadFile 合法域名 |
udpdomain | string array | udp 合法域名 |
tcpdomain | string array | tcp 合法域名 |
invalid_requestdomain | string array | request 不合法域名 |
invalid_wsrequestdomain | string array | socket 不合法域名 |
invalid_uploaddomain | string array | uploadFile 不合法域名 |
invalid_downloaddomain | string array | downloadFile 不合法域名 |
invalid_udpdomain | string array | udp 不合法域名 |
invalid_tcpdomain | string array | tcp 不合法域名 |
no_icp_domain | string array | 没有经过 icp 备案的域名 |
返回结果示例:
"errcode": 85303,
"errmsg": "no domain to modify after filtered, please confirm the domain has been set in miniprogram or open, and follows the rule of domains. Besides, please confirm all domains have ICP licenses",
"requestdomain": [],
"wsrequestdomain": [],
"uploaddomain": [],
"downloaddomain": [],
"udpdomain": [],
"tcpdomain": [],
"invalid_requestdomain": [],
"invalid_wsrequestdomain": [
"wss://melody.weixin.melody44.com"
],
"invalid_uploaddomain": [
"https://melody.weixin.melody33.com"
],
"invalid_downloaddomain": [],
"invalid_udpdomain": [
"udp://melody.weixin.melody22.com"
],
"invalid_tcpdomain": [
"tcp://melody.weixin.melody22.com"
],
"no_icp_domain": [
"https://melody.weixin.melody.com:443"
]
# 返回码说明
errcode | errmsg | 说明 |
---|---|---|
0 | ok | 成功 |
85015 | 该账号不是小程序账号 | |
85016 | 域名数量超过限制 | |
85017 | no domain to modify after filtered, please confirm the domain has been set in miniprogram or open | 域名输入为空,或者没有新增域名,请确认小程序已经添加了域名或该域名是否没有在第三方平台添加 |
85018 | 域名没有在第三方平台设置 | |
85301 | no domain to modify after filtered, please confirm the domain has been set in miniprogram or open, and follows the rule of domains。 | 存在 “不符合域名规则的域名”导致无修改。 |
85302 | no domain to modify after filtered, please confirm all domains have ICP licenses | 存在 “ 缺少 ICP 备案的域名”导致无修改 |
85303 | no domain to modify after filtered, please confirm the domain has been set in miniprogram or open, and follows the rule of domains. Besides, please confirm all domains have ICP licenses | 同时存在“不符合域名规则的域名”以及“ 缺少 ICP 备案的域名”导致无修改。 |
其他错误码 | 请查看全局错误码 |