运维中心 /getDomainInfo # operation.getDomainInfo > 本接口应在服务器端调用,详细说明参见[服务端API](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html)。 > 本接口支持[云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)。需开发者工具版本 >= `1.02.1904090`(最新[稳定版下载](https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html)),`wx-server-sdk` >= `0.4.0` 查询域名配置 调用方式: - [HTTPS 调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/operation/operation.getDomainInfo.html#method-http) - [云调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/operation/operation.getDomainInfo.html#method-cloud) ## HTTPS 调用 ### 请求地址 ```text GET https://api.weixin.qq.com/wxa/getwxadevinfo?access_token=ACCESS_TOKEN ``` ### 请求参数 | 属性 | 类型 | 默认值 | 必填 | 说明 | | :------------------------------------ | :----- | :----- | :--- | :----------------------------------------------------------- | | access_token / cloudbase_access_token | string | | 是 | [接口调用凭证](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html) | | action | string | | 否 | 查询配置域名的类型, 可选值如下: 1. getbizdomain 返回业务域名 2. getserverdomain 返回服务器域名 3. 不指明返回全部 | ### 返回值 ### Object | 属性 | 类型 | 说明 | | :-------------- | :------------- | :----------------------- | | requestdomain | Array.<string> | request合法域名列表 | | wsrequestdomain | Array.<string> | socket合法域名列表 | | uploaddomain | Array.<string> | uploadFile合法域名列表 | | downloaddomain | Array.<string> | downloadFile合法域名列表 | | udpdomain | Array.<string> | udp合法域名列表 | | bizdomain | Array.<string> | 业务域名列表 | | errcode | number | 错误码 | | errmsg | number | 错误信息 | **errcode 的合法值** | 值 | 说明 | 最低版本 | | :------ | :--------------- | :------- | | 9410018 | 个人账号不可调用 | | ### 返回示例 ```json { "errcode": 0, "errmsg": "ok", "requestdomain": [ "https://www.example.com" ], "wsrequestdomain": [ "wss://www.qq.com" ], "uploaddomain": [], "downloaddomain": [ "https://www.qq.com" ], "udpdomain": [ "udp://www.example.com" ], "bizdomain": [ "https://www.qq.com" ] } ``` ## 云调用 > [云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)是微信云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过 `wx-server-sdk` 使用。 ### 接口方法 ```js openapi.operation.getDomainInfo ``` > 需在 `config.json` 中配置 `operation.getDomainInfo` API 的权限,[详情](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html#usage-3) ### 请求参数 | 属性 | 类型 | 默认值 | 必填 | 说明 | | :----- | :----- | :----- | :--- | :----------------------------------------------------------- | | action | string | | 否 | 查询配置域名的类型, 可选值如下: 1. getbizdomain 返回业务域名 2. getserverdomain 返回服务器域名 3. 不指明返回全部 | ### 返回值 ### Object | 属性 | 类型 | 说明 | | :-------------- | :------------- | :----------------------- | | requestdomain | Array.<string> | request合法域名列表 | | wsrequestdomain | Array.<string> | socket合法域名列表 | | uploaddomain | Array.<string> | uploadFile合法域名列表 | | downloaddomain | Array.<string> | downloadFile合法域名列表 | | udpdomain | Array.<string> | udp合法域名列表 | | bizdomain | Array.<string> | 业务域名列表 | | errCode | number | 错误码 | | errMsg | number | 错误信息 | **errCode 的合法值** | 值 | 说明 | 最低版本 | | :--- | :--- | :------- | | 0 | 成功 | | ### 异常 ### Object 抛出的异常 | 属性 | 类型 | 说明 | | :------ | :----- | :------- | | errCode | number | 错误码 | | errMsg | number | 错误信息 | **errCode 的合法值** | 值 | 说明 | 最低版本 | | :------ | :--------------- | :------- | | 9410018 | 个人账号不可调用 | | ### 请求示例 ```js const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV, }) exports.main = async (event, context) => { try { const result = await cloud.openapi.operation.getDomainInfo({ "action": '' }) return result } catch (err) { return err } } ``` ### 返回示例 ```json const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV, }) exports.main = async (event, context) => { try { const result = await cloud.openapi.operation.getDomainInfo({ "errcode": 0, "errmsg": 'ok', "requestdomain": [ "https://www.example.com" ], "wsrequestdomain": [ "wss://www.qq.com" ], "uploaddomain": [], "downloaddomain": [ "https://www.qq.com" ], "udpdomain": [ "udp://www.example.com" ], "bizdomain": [ "https://www.qq.com" ] }) return result } catch (err) { return err } } ```