文档中心

基于OpenAPI规范的标准化技术文档枢纽,提供版本化、交互式、机器可读的API全生命周期管理解决方案。

未找到包含 "" 的相关产品

产品目录

ShowDoc文档解析

服务正常 全站会员免费包年包月按量计费次数包 网盘云存储解析 2025-11-02 10 万次

这是一款专为 ShowDoc 文档平台打造的智能导出工具,支持一键获取完整文档结构与内容。只需提供文档链接,即可快速解析项目下所有页面、目录层级及详细内容,支持密码保护的私有文档访问。接口自动处理复杂的文档树结构,递归获取所有子目录和页面内容,返回结构化 JSON 数据。完美适用于文档备份、迁移、二次开发等场景,让文档管理更轻松高效。

调用权限
正常
请求频率限制
10次/秒 (10 QPS)
免费额度
4000
参考价格
0.003元/次

计费优先级(按已开通的计费类型依次校验):

全站会员->单独包月->次数包->点数计费->账户余额->免费额度

账户余额:

该产品支持账户余额抵扣,每次扣除金额:0.005 元/次

全站会员:

全站会员有效期内,可免费使用本产品。

包年包月:

包月价格 包季价格 包年价格
¥ 50.00 约 1.61 元/天 ¥ 120.00 约 1.33 元/天 ¥ 360.00 约 0.98 元/天

次数包:

额度 价格 有效期
10000 (次) ¥ 30 低至0.003/次 一年
100000 (次) ¥ 268 低至0.00268/次 一年
1000000 (次) ¥ 2180 低至0.00218/次 一年

免费额度:

总免费额度 每月免费额度 每日免费额度
4000 (次) 400 (次) 包含在总免费额度 20 (次) 包含在总免费额度

请求限制:

免费/测试用户请求频率限制 请求频率总限制 全站会员请求频率限制 每日请求次数总限制
5秒1次 每个免费用户的QPS总限制 1秒10次 每个用户QPS总限制 1秒10次 每个全站会员用户的QPS总限制 100000 (次) 每个用户每日请求总次数

其他准入要求:

  • 账户余额/点数/次数包计费的用户,不限制请求频率(QPS)
  • 账户余额/点数/次数包计费的用户,不限制每日请求次数(RPD)
  • 接口地址: https://www.ninyao.cn/api/swd/index

    返回格式: application/json

    请求方式: HTTPGET

    请求HEADER:

    名称值
    Content-Typeapplication/x-www-form-urlencoded;charset:utf-8;

    请求参数说明:

    名称必填类型示例值说明
    url是stringhttps://www.showdoc.com.cn/128719739414963ShowDoc文档地址,支持数字ID或字符串标识符格式
    pass否string123456文档访问密码(如果文档设置了密码保护则必填)

    返回参数说明:

    名称类型说明
    codeint状态码(200:成功, 400:参数错误, 401:密码错误, 404:文档不存在, 500:服务器错误, 503:网络请求失败)
    messagestring状态信息描述
    tipstring接口来源提示信息
    dataobject文档数据对象(仅成功时返回)
    data.item_namestring项目名称
    data.structurearray文档结构数组,包含所有页面和目录的层级关系
    structure[].typestring节点类型: "page"(页面) 或 "catalog"(目录)
    structure[].page_idstring页面ID(仅type为page时存在)
    structure[].titlestring页面标题(仅type为page时存在)
    structure[].contentstring页面内容,支持Markdown格式(仅type为page时存在)
    structure[].namestring目录名称(仅type为catalog时存在)
    structure[].childrenarray子节点数组,递归包含子目录和页面(仅type为catalog时存在)

    免责声明:

    本服务仅供个人学习、学术研究目的使用,未经授权,请勿分享、传播输入及生成的文本、图片内容。用户在从事与本服务相关的一切行为(包括但不限于访问浏览、利用、转载、宣传介绍)时,应以善意且谨慎的态度行事并承担相应的风险和责任。用户需确保不得利用本服务进行危害国家安全和社会公共利益、扰乱经济秩序和社会秩序、侵犯他人合法权益等法律、行政法规禁止的活动,并且自定义输入文本不得包含违反法律法规、政治相关、侵犯他人合法权益的内容。对于用户因使用本服务而导致的任何损失或风险,包括但不限于由于使用本服务而产生的错误、疏忽、中断、删除、故障、延迟或通讯线路故障所导致的任何损失或损害,本服务的开发者将不承担任何责任。

    请求示例:

    https://www.ninyao.cn/api/swd/index?key=你的key&url=看文档&pass=看文档

    返回示例:

    {
    • "code": 200,
    • "message": "success",
    • "tip": "此接口由您要数据独家开发,购买开源接口源码联系WX:gzdswj",
    • -
      "data": {
      • "item_name": "黑马优购",
      • -
        "structure": [
        • -
          {
          • "type": "catalog",
          • "name": "首页",
          • -
            "children": [
            • -
              {
              • "type": "page",
              • "page_id": "2513235043485226",
              • "title": "轮播图",
              • "content": "**简要描述:** - 轮播图**请求URL:** - `https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata` **请求方式:**- GET**参数:** 无 **返回示例**``` json{ "message": [ { "image_src": "https://api-hmugo-web.itheima.net/pyg/banner1.png", "open_type": "navigate", "goods_id": 129, "navigator_url": "/pages/goods_detail/index?goods_id=129" } ], "meta": { "msg": "获取成功", "status": 200 }}``` **返回参数说明** | 参数名 | 类型 | 说明 || :------------ | :----- | ------------------------------------ || image_src | string | 图片路径 || open_type | string | 打开方式 || goods_id | number | 商品id || navigator_url | string | 导航链接 | **备注** - 更多返回错误代码请看首页的错误代码描述"
              },
            • -
              {
              • "type": "page",
              • "page_id": "2513278140891548",
              • "title": "导航",
              • "content": "**简要描述:** - 导航菜单**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/home/catitems `**请求方式:**- GET**参数:** 无 **返回示例**``` { "message": [ { "name": "分类", "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_4@2x.png", "open_type": "switchTab", "navigator_url": "/pages/category/index" }, { "name": "秒杀拍", "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_3@2x.png" }, { "name": "超市购", "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_2@2x.png" }, { "name": "母婴品", "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_1@2x.png" } ], "meta": { "msg": "获取成功", "status": 200 }}``` **返回参数说明** |参数名|类型|说明||:----- |:-----|----- ||name |string |标题名称 ||image_src |string |图片路径 | **备注** - 更多返回错误代码请看首页的错误代码描述"
              },
            • -
              {
              • "type": "page",
              • "page_id": "2513282464078443",
              • "title": "楼层",
              • "content": "**简要描述:** - 楼层**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/home/floordata `**请求方式:**- GET**参数:** 无 **返回示例**``` { "message": [ { "floor_title": { "name": "时尚女装", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor01_title.png" }, "product_list": [ { "name": "优质服饰", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor01_1@2x.png", "image_width": "232", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=服饰" }, { "name": "春季热门", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor01_2@2x.png", "image_width": "233", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=热" }, { "name": "爆款清仓", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor01_3@2x.png", "image_width": "233", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=爆款" }, { "name": "倒春寒", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor01_4@2x.png", "image_width": "233", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=春季" }, { "name": "怦然心动", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor01_5@2x.png", "image_width": "233", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=心动" } ] }, { "floor_title": { "name": "户外活动", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor02_title.png" }, "product_list": [ { "name": "勇往直前", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor02_1@2x.png", "image_width": "232", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=户外" }, { "name": "户外登山包", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor02_2@2x.png", "image_width": "273", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=登山包" }, { "name": "超强手套", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor02_3@2x.png", "image_width": "193", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=手套" }, { "name": "户外运动鞋", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor02_4@2x.png", "image_width": "193", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=运动鞋" }, { "name": "冲锋衣系列", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor02_5@2x.png", "image_width": "273", "open_type": "navigate", "navigator_url": "/pages/goods_list/index?query=冲锋衣" } ] }, { "floor_title": { "name": "箱包配饰", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor03_title.png" }, "product_list": [ { "name": "清新气质", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor03_1@2x.png", "image_width": "232", "open_type": "navigate", "navigator_url": "/pages/goods_list?query=饰品" }, { "name": "复古胸针", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor03_2@2x.png", "image_width": "263", "open_type": "navigate", "navigator_url": "/pages/goods_list?query=胸针" }, { "name": "韩版手链", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor03_3@2x.png", "image_width": "203", "open_type": "navigate", "navigator_url": "/pages/goods_list?query=手链" }, { "name": "水晶项链", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor03_4@2x.png", "image_width": "193", "open_type": "navigate", "navigator_url": "/pages/goods_list?query=水晶项链" }, { "name": "情侣表", "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor03_5@2x.png", "image_width": "273", "open_type": "navigate", "navigator_url": "/pages/goods_list?query=情侣表" } ] } ], "meta": { "msg": "获取成功", "status": 200 }}``` **返回参数说明** |参数名|类型|说明||:----- |:-----|----- ||floor_title |string |一级分类标题 ||product_list |array |一级分类内容 ||name |string |名称 ||image_src |string |图片路径 ||image_width |string |图片宽度 ||open_type |string |打开方式 ||navigator_url |string |跳转连接 | **备注** - 更多返回错误代码请看首页的错误代码描述"
              }
            ]
          },
        • -
          {
          • "type": "catalog",
          • "name": "分类",
          • -
            "children": [
            • -
              {
              • "type": "page",
              • "page_id": "2516997897914014",
              • "title": "商品分类",
              • "content": "​ **简要描述:** - 商品分类**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/categories `**请求方式:**- GET**参数:** 无 **返回示例**``` json{ "message": [ { "cat_id": 1, "cat_name": "大家电", "cat_pid": 0, "cat_level": 0, "cat_deleted": false, "cat_icon": "", "children": [ { "cat_id": 3, "cat_name": "电视", "cat_pid": 1, "cat_level": 1, "cat_deleted": false, "cat_icon": "", "children": [ { "cat_id": 5, "cat_name": "曲面电视", "cat_pid": 3, "cat_level": 2, "cat_deleted": false, "cat_icon": "https://api-hmugo-web.itheima.net/full/2fb113b32f7a2b161f5ee4096c319afedc3fd5a1.jpg" } ] } ] } ], "meta": { "msg": "获取成功", "status": 200 }}``` **返回参数说明** |参数名|类型|||:----- |:-----|----- ||cat_id |int |分类id||cat_name |string |分类名称||children |array |子节点||cat_icon |string |图标| **备注** - 更多返回错误代码请看首页的错误代码描述"
              }
            ]
          },
        • -
          {
          • "type": "catalog",
          • "name": "商品",
          • -
            "children": [
            • -
              {
              • "type": "page",
              • "page_id": "2526159696464209",
              • "title": "商品列表搜索",
              • "content": "**简要描述:** - 商品列表搜索**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/goods/search `**请求方式:**- GET**参数:** |参数名|必选|类型|说明||:---- |:---|:----- |----- ||query |否 |string |关键字 ||cid |否 |string | 分类id ||pagenum |否 |number | 页码 ||pagesize |否 |number | 页容量 | **返回示例**``` json{ "message": { "total": 10, "pagenum": 1, "goods": [ { "goods_id": 57445, "cat_id": 9, "goods_name": "创维(Skyworth)65V9E 65英寸25核4K HDR高清智能电视", "goods_price": 6499, "goods_number": 100, "goods_weight": 100, "goods_big_logo": "", "goods_small_logo": "", "add_time": 1516663280, "upd_time": 1516663280, "hot_mumber": 0, "is_promote": false, "cat_one_id": 1, "cat_two_id": 3, "cat_three_id": 9 } ] }, "meta": { "msg": "获取成功", "status": 200 }}``` **返回参数说明** | | | || ---------------- | ------------ | ---- || 参数名 | 参数说明 | 备注 || total | 总条数 | || pagenum | 当前页数 | || goods_id | 商品ID | || cat_id | 分类ID | || goods_name | 商品名称 | || goods_price | 商品价格 | || goods_number | 商品数量 | || goods_weight | 商品重量 | || goods_big_logo | 商品大图标 | || goods_small_logo | 商品小图标 | || add_time | 商品添加时间 | || upd_time | 商品更新时间 | || hot_mumber | 热门商品数 | || cat_one_id | 所属一级分类 | || cat_two_id | 所属二级分类 | || cat_three_id | 所属三级分类 | | **备注** - 更多返回错误代码请看首页的错误代码描述"
              },
            • -
              {
              • "type": "page",
              • "page_id": "2526175298570888",
              • "title": "商品详情",
              • "content": "​ **简要描述:** - 商品详情**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/goods/detail `**请求方式:**- GET**参数:** |参数名|必选|类型|说明||:---- |:---|:----- |----- ||goods_id |是 |number |商品id | **返回示例**``` { "message": { "goods_id": 8888, "cat_id": 1085, "goods_name": "spike 经典武士大马士革直刀(微型) 户外野营直刀 收藏礼品刀 饰品刀具", "goods_price": 500, "goods_number": 100, "goods_weight": 100, "goods_introduce": "富文本内容", "goods_state": 2, "is_del": "0", "add_time": 1516361489, "upd_time": 1516361489, "delete_time": null, "hot_mumber": 0, "is_promote": false, "cat_one_id": 995, "cat_two_id": 1075, "cat_three_id": 1085, "goods_cat": "995,1075,1085", "pics": [ { "pics_id": 38711, "goods_id": 8888, "pics_big": "http://image1.suning.cn/uimg/b2c/newcatentries/0070134290-000000000149003877_1_800x800.jpg", "pics_mid": "http://image1.suning.cn/uimg/b2c/newcatentries/0070134290-000000000149003877_1_400x400.jpg", "pics_sma": "http://image1.suning.cn/uimg/b2c/newcatentries/0070134290-000000000149003877_1_200x200.jpg", "pics_big_url": "http://image1.suning.cn/uimg/b2c/newcatentries/0070134290-000000000149003877_1_800x800.jpg", "pics_mid_url": "http://image1.suning.cn/uimg/b2c/newcatentries/0070134290-000000000149003877_1_400x400.jpg", "pics_sma_url": "http://image1.suning.cn/uimg/b2c/newcatentries/0070134290-000000000149003877_1_200x200.jpg" } ], "attrs": [ { "goods_id": 8888, "attr_id": 9210, "attr_value": "户外直刀", "add_price": 0, "attr_name": "主体参数-类别", "attr_sel": "only", "attr_write": "manual", "attr_vals": "放大镜" } ] }, "meta": { "msg": "获取成功", "status": 200 }}``` **返回参数说明** | | | || ---------------- | ------------ | ---- || 参数名 | 参数说明 | 备注 || goods_id | 商品ID | || cat_id | 分类ID | || goods_name | 商品名称 | || goods_price | 商品价格 | || goods_number | 商品数量 | || goods_weight | 商品重量 | || goods_big_logo | 商品大图标 | || goods_small_logo | 商品小图标 | || add_time | 商品添加时间 | || upd_time | 商品更新时间 | || hot_mumber | 热门商品数 | || cat_one_id | 所属一级分类 | || cat_two_id | 所属二级分类 | || cat_three_id | 所属三级分类 | || goods_introduce | 商品介绍 | || pics | 商品图片列表 | || attrs | 商品属性列表 | | **备注** - 更多返回错误代码请看首页的错误代码描述"
              },
            • -
              {
              • "type": "page",
              • "page_id": "2526176842444912",
              • "title": "商品搜索",
              • "content": "​ **简要描述:** - 搜索建议查询**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/goods/qsearch `**请求方式:**- GET**参数:** |参数名|必选|类型|说明||:---- |:---|:----- |----- ||query |是 |string |关键字 | **返回示例**``` { "message": [ { "goods_id": 57444, "goods_name": "创维(Skyworth)42X6 42英寸10核智能酷开网络平板液晶电视(黑色)" } ], "meta": { "msg": "获取成功", "status": 200 }}``` **返回参数说明** |参数名|类型|说明||:----- |:-----|----- ||goods_id |number |商品id ||goods_name |string |商品名称 | **备注** - 更多返回错误代码请看首页的错误代码描述"
              }
            ]
          },
        • -
          {
          • "type": "catalog",
          • "name": "用户",
          • -
            "children": [
            • -
              {
              • "type": "page",
              • "page_id": "2612400282844951",
              • "title": "获取用户token",
              • "content": "​ **简要描述:** - 获取用户token**请求URL:** - `https://api-hmugo-web.itheima.net/api/public/v1/users/wxlogin`**请求方式:**- POST **参数:** 以下字段主要用作后台服务器生成用户token所有,无特殊用意| 参数名 | 必选 | 类型 | 参数说明 || ------------- | ---- | ---- | ------------------------------ || encryptedData | 是 | string | 执行小程序 获取用户信息后 得到 || rawData | 是 | string | 执行小程序 获取用户信息后 得到 || iv | 是 | string | 执行小程序 获取用户信息后 得到 || signature | 是 | string | 执行小程序 获取用户信息后 得到 || code | 是 | string | 执行小程序登录后获取 | **返回示例**``` json{ "message": { "user_id": 23, "user_email_code": null, "is_active": null, "user_sex": "男", "user_qq": "", "user_tel": "", "user_xueli": "本科", "user_hobby": "", "user_introduce": null, "create_time": 1562221487, "update_time": 1562221487, "token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo" }, "meta": { "msg": "登录成功", "status": 200 }}``` **返回参数说明** |参数名|类型|说明||:----- |:-----|----- ||token |string |用户的唯一凭据,后期用在其他敏感接口的验证 |"
              }
            ]
          },
        • -
          {
          • "type": "catalog",
          • "name": "支付",
          • -
            "children": [
            • -
              {
              • "type": "page",
              • "page_id": "2612486239891213",
              • "title": "获取支付参数",
              • "content": "​ **简要描述:** - 获取支付参数**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/my/orders/req_unifiedorder `**请求方式:**- POST **请求头参数:** | 参数名 | 必选 | 类型 | 说明 || ------------- | ---- | ------ | ------------------------- || Authorization | 是 | string | 用户登录成功获取的token值 |**请求体参数:**| 参数名 | 必选 | 类型 | 说明 || ------------ | ---- | ------ | -------- || order_number | 是 | string | 订单编号 | **返回示例**``` json{ "message": { "pay": { "timeStamp": "1564730510", "nonceStr": "SReWbt3nEmpJo3tr", "package": "prepay_id=wx02152148991420a3b39a90811023326800", "signType": "MD5", "paySign": "3A6943C3B865FA2B2C825CDCB33C5304" }, "order_number": "HMDD20190802000000000422" }, "meta": { "msg": "预付订单生成成功", "status": 200 }}``` **返回参数说明** |参数名|类型|说明||:----- |:-----|----- ||pay |object |该对象内的参数,为调用微信支付所必须 |"
              }
            ]
          },
        • -
          {
          • "type": "catalog",
          • "name": "订单",
          • -
            "children": [
            • -
              {
              • "type": "page",
              • "page_id": "2612148628877795",
              • "title": "创建订单",
              • "content": " **简要描述:** - 创建订单**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/my/orders/create `**请求方式:**- POST **请求头参数:** | 参数名 | 必选 | 类型 | 说明 || ------------- | ---- | ------ | ------------------------- || Authorization | 是 | string | 用户登录成功获取的token值 |**请求体参数**:|参数名|必选|类型|说明||:---- |:---|:----- |----- ||order_price |是 |string |订单总价格 ||consignee_addr |是 |string | 收货地址 ||goods |是 |Array | 订单数组 |**goods字段说明**| 参数名 | 必选 | 类型 | 说明 || ------------ | ---- | ------ | ---------- || goods_id | 是 | number | 商品id || goods_number | 是 | number | 购买的数量 || goods_price | 是 | number | 单价 | **返回示例**``` { "error_code": 0, "data": { "uid": "1", "username": "12154545", "name": "吴系挂", "groupid": 2 , "reg_time": "1436864169", "last_login_time": "0", } }``` **返回参数说明** | 参数名 | 类型 | 参数说明 || -------------- | ------ | ------------ || order_id | string | 订单唯一ID || user_id | string | 用户ID || order_number | string | 订单编号 || order_price | number | 订单价格 || order_pay | number | 订单支付方式 || consignee_addr | string | 订单地址 || pay_status | number | 订单支付状态 |"
              },
            • -
              {
              • "type": "page",
              • "page_id": "2612723166377091",
              • "title": "查看订单支付状态",
              • "content": "​ **简要描述:** - 查看订单支付状态**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/my/orders/chkOrder `**请求方式:**- POST**请求头参数:** | 参数名 | 必选 | 类型 | 说明 || ------------- | ---- | ------ | ------------------------- || Authorization | 是 | string | 用户登录成功获取的token值 |**请求体参数**:| 参数名 | 必选 | 类型 | 说明 || ------------ | ---- | ------ | -------- || order_number | 是 | string | 订单编号 | **返回示例**``` json{ "message": "支付成功", "meta": { "msg": "验证成功", "status": 200 }}```"
              },
            • -
              {
              • "type": "page",
              • "page_id": "2612830563673346",
              • "title": "历史订单查询",
              • "content": "​ **简要描述:** - 历史订单查询**请求URL:** - ` https://api-hmugo-web.itheima.net/api/public/v1/my/orders/all `**请求方式:**- GET**请求头参数:**| 参数名 | 必选 | 类型 | 说明 || ------------- | ---- | ------ | ------------------------- || Authorization | 是 | string | 用户登录成功获取的token值 |**请求体参数**:| 参数名 | 必选 | 类型 | 说明 || ------ | ---- | ------ | ---------------------------- || type | 是 | number | 1:全部订单 2:待付款 3:待发货 | **返回示例**``` json{ "message": { "count": 1, "orders": [ { "order_id": 428, "user_id": 23, "order_number": "HMDD20190802000000000428", "order_price": 13999, "order_pay": "0", "is_send": "否", "trade_no": "", "order_fapiao_title": "个人", "order_fapiao_company": "", "order_fapiao_content": "", "consignee_addr": "广东省广州市海珠区新港中路397号", "pay_status": "1", "create_time": 1564731518, "update_time": 1564731518, "order_detail": null, "goods": [ { "id": 717, "order_id": 428, "goods_id": 43986, "goods_price": 13999, "goods_number": 1, "goods_total_price": 13999, "goods_name": "海信(Hisense)LED55MU9600X3DUC 55英寸 4K超高清量子点电视 ULED画质 VIDAA系统", "goods_small_logo": "http://image5.suning.cn/uimg/b2c/newcatentries/0000000000-000000000160455569_1_400x400.jpg" } ], "total_count": 1, "total_price": 13999 } ] }, "meta": { "msg": "获取订单列表成功", "status": 200 }}```"
              }
            ]
          }
        ]
      }
    }
    错误码类型说明
    403int没有权限
    400int参数传递不正确
    500int服务器内部错误
    本示例代码演示了接口的基础调用流程,开发者需自行将代码中的默认值替换为实际的API接口认证信息。
    
    <?php
    /**
     * API请求DEMO
     * 
     * 本demo支持常见的HTTP请求方法(GET/POST/PUT/DELETE等)
     */
    
     //基本配置
    $api_key = '你的接口密钥,登录控制台后在密钥管理页面申请';
    $secret_key = '';
    
    // API请求示例:
    try {
        $client = new ApiClient($api_key, $secret_key);
        $client->setTimeout(10);
        $client->setVerifySSL(false); // 关闭SSL验证
    
        // GET请求示例
        echo "=== 开始GET请求 ===\n";
        $response = $client->get('https://www.ninyao.cn/api/swd/index', [
            'key' => $api_key,
            'key2' => '其他参数'
        ]);
        print_r($response);
        //print_r($client->getLastRequestInfo());
        /* 
        // POST表单示例
        echo "\n=== 开始POST请求 ===\n";
        $response = $client->post('接口地址', [
            'key' => $api_key,
            'key2' => '其他参数'
        ]);
        print_r($response);
        print_r($client->getLastRequestInfo());
    
        // POST JSON示例
        echo "\n=== 开始POST JSON请求 ===\n";
        $response = $client->postJson('接口地址', [
            'key' => $api_key,
            'key2' => '其他参数'
        ]);
        print_r($response);
        print_r($client->getLastRequestInfo());
         */
    } catch (ApiClientException $e) {
        echo "API请求错误: " . $e->getMessage();
        if ($e->getCode() > 0) {
            echo " (HTTP状态码: " . $e->getCode() . ")";
        }
        print_r($client->getLastRequestInfo() ?? []);
    }
    
    /**
     * API客户端类
     * 
     * 提供了一个简单的HTTP API客户端实现,支持常见的HTTP请求方法(GET/POST/PUT/DELETE等)
     * 具有以下主要功能:
     * - 支持 API 密钥和签名认证
     * - 可配置请求超时和SSL验证
     * - 支持自定义请求头
     * - 支持表单和JSON格式的请求体
     * - 自动解析响应结果
     * - 提供详细的请求信息记录
     * 
     * 使用示例:
     * ```
     * $client = new ApiClient('https://api.example.com', 'api_key', 'secret_key');
     * $response = $client->get('/users', ['page' => 1]);
     * ```
     * 
     * @throws ApiClientException 当API请求失败时抛出异常
     */
    class ApiClient
    {
        private $apiKey;
        private $secretKey;
        private $timeout = 30;
        private $verifySSL = true;
        private $lastRequestInfo = [];
        private $defaultHeaders = [];
    
        /**
         * 构造函数
         * 
         * @param string $apiKey  API密钥(可选)
         * @param string $secretKey 签名密钥(可选)
         */
        public function __construct(string $apiKey = '', string $secretKey = '')
        {
            $this->apiKey = $apiKey;
            $this->secretKey = $secretKey;
        }
    
        /**
         * 设置请求超时时间(秒)
         */
        public function setTimeout(int $seconds): self
        {
            $this->timeout = $seconds;
            return $this;
        }
    
        /**
         * 设置是否验证SSL证书
         */
        public function setVerifySSL(bool $verify): self
        {
            $this->verifySSL = $verify;
            return $this;
        }
    
        /**
         * 添加默认请求头
         */
        public function addDefaultHeader(string $name, string $value): self
        {
            $this->defaultHeaders[$name] = $value;
            return $this;
        }
    
        /**
         * 发送GET请求
         * 
         * @param string $endpoint 接口端点
         * @param array  $query    查询参数
         * @param array  $headers  额外请求头
         */
        public function get(string $endpoint, array $query = [], array $headers = []): array
        {
            return $this->request('GET', $endpoint, [
                'query' => $query,
                'headers' => $headers
            ]);
        }
    
        /**
         * 发送POST请求(表单格式)
         * 
         * @param string $endpoint 接口端点
         * @param array  $data     POST数据
         * @param array  $headers  额外请求头
         */
        public function post(string $endpoint, array $data = [], array $headers = []): array
        {
            return $this->request('POST', $endpoint, [
                'form_data' => $data,
                'headers' => $headers
            ]);
        }
    
        /**
         * 发送POST请求(JSON格式)
         * 
         * @param string $endpoint 接口端点
         * @param array  $data     POST数据
         * @param array  $headers  额外请求头
         */
        public function postJson(string $endpoint, array $data = [], array $headers = []): array
        {
            return $this->request('POST', $endpoint, [
                'json' => $data,
                'headers' => array_merge(['Content-Type' => 'application/json'], $headers)
            ]);
        }
    
        /**
         * 发送PUT请求
         */
        public function put(string $endpoint, array $data = [], array $headers = []): array
        {
            return $this->request('PUT', $endpoint, [
                'json' => $data,
                'headers' => $headers
            ]);
        }
    
        /**
         * 发送DELETE请求
         */
        public function delete(string $endpoint, array $data = [], array $headers = []): array
        {
            return $this->request('DELETE', $endpoint, [
                'json' => $data,
                'headers' => $headers
            ]);
        }
    
        /**
         * 获取最后一次请求的详细信息
         */
        public function getLastRequestInfo(): array
        {
            return $this->lastRequestInfo;
        }
    
        /**
         * 基础请求方法
         */
        private function request(string $method, string $endpoint, array $options = []): array
        {
            // 初始化cURL
            $ch = curl_init();
            $url = ltrim($endpoint, '/');
    
            // 准备请求头
            $headers = $this->prepareHeaders($options['headers'] ?? []);
    
            // 处理查询参数
            if (!empty($options['query'])) {
                $url .= '?' . http_build_query($options['query']);
            }
    
            // 处理请求体
            $postData = null;
            if (isset($options['form_data'])) {
                $postData = http_build_query($options['form_data']);
                $headers[] = 'Content-Type: application/x-www-form-urlencoded';
            } elseif (isset($options['json'])) {
                $postData = json_encode($options['json']);
                $headers[] = 'Content-Type: application/json';
            }
    
            // 设置cURL选项
            curl_setopt_array($ch, [
                CURLOPT_URL => $url,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_CUSTOMREQUEST => $method,
                CURLOPT_HTTPHEADER => $headers,
                CURLOPT_TIMEOUT => $this->timeout,
                CURLOPT_SSL_VERIFYPEER => $this->verifySSL,
                CURLOPT_SSL_VERIFYHOST => $this->verifySSL,
                CURLOPT_HEADER => true,
            ]);
    
            if ($method !== 'GET' && $postData !== null) {
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
            }
    
            // 执行请求
            $response = curl_exec($ch);
            $error = curl_error($ch);
            $info = $this->lastRequestInfo = curl_getinfo($ch);
            curl_close($ch);
    
            // 处理错误
            if ($error) {
                throw new ApiClientException("cURL请求失败: " . $error);
            }
    
            // 分离响应头和响应体
            $headerSize = $info['header_size'];
            $responseHeaders = substr($response, 0, $headerSize);
            $responseBody = substr($response, $headerSize);
    
            // 解析响应
            $result = json_decode($responseBody, true) ?? $responseBody;
    
            // 检查HTTP状态码
            if ($info['http_code'] >= 400) {
                $errorMsg = is_array($result) ? ($result['message'] ?? $responseBody) : $responseBody;
                throw new ApiClientException("API请求失败: " . $errorMsg, $info['http_code']);
            }
    
            return [
                'status' => $info['http_code'],
                'headers' => $this->parseHeaders($responseHeaders),
                'data' => $result
            ];
        }
    
        /**
         * 准备请求头(自动添加签名)
         */
        private function prepareHeaders(array $headers): array
        {
            // 合并默认头
            $headers = array_merge($this->defaultHeaders, $headers);
    
            // 添加签名头
            if ($this->apiKey && $this->secretKey) {
                $timestamp = time();
                $signString = "key={$this->apiKey}&timestamp={$timestamp}";
                $signature = hash_hmac('sha256', $signString, $this->secretKey);
    
                $headers['X-Api-Key'] = $this->apiKey;
                $headers['X-Api-Timestamp'] = $timestamp;
                $headers['X-Api-Sign'] = $signature;
            }
    
            // 转换为cURL格式
            $curlHeaders = [];
            foreach ($headers as $name => $value) {
                $curlHeaders[] = "$name: $value";
            }
    
            return $curlHeaders;
        }
    
        /**
         * 解析响应头
         */
        private function parseHeaders(string $headers): array
        {
            $parsed = [];
            foreach (explode("\r\n", $headers) as $i => $line) {
                if ($i === 0) {
                    $parsed['HTTP_CODE'] = $line;
                } else {
                    $parts = explode(': ', $line, 2);
                    if (count($parts) === 2) {
                        $parsed[$parts[0]] = $parts[1];
                    }
                }
            }
            return $parsed;
        }
    }
    
    class ApiClientException extends \Exception
    {
        // 自定义异常类
    }
    
    
    
    
    
    
    /**
     * 原生JS通用API请求函数(支持GET/POST,JSON格式)
     * @param {string} url - API接口完整地址
     * @param {string} method - 请求方法,仅支持GET/POST
     * @param {object} [data={}] - 请求参数(GET拼接到URL,POST作为JSON请求体)
     * @returns {Promise} - 返回接口响应的JSON数据
     */
    async function requestApi(url, method, data = {}) {
      try {
        // 处理GET请求:拼接参数到URL
        let requestUrl = url;
        if (method.toUpperCase() === 'GET' && Object.keys(data).length > 0) {
          const params = new URLSearchParams(data).toString();
          requestUrl = `${requestUrl}${requestUrl.includes('?') ? '&' : '?'}${params}`;
        }
    
        // 配置请求选项
        const requestOptions = {
          method: method.toUpperCase(),
          headers: { 'Content-Type': 'application/json' },
          credentials: 'include' // 跨域时携带Cookie,不需要可改为omit
        };
    
        // 处理POST请求:设置JSON请求体
        if (method.toUpperCase() === 'POST') {
          requestOptions.body = JSON.stringify(data);
        }
    
        // 发送请求并处理响应
        const response = await fetch(requestUrl, requestOptions);
        if (!response.ok) throw new Error(`请求失败:${response.status} ${response.statusText}`);
        const result = await response.json(); // 自动解析JSON响应
        return result;
    
      } catch (error) {
        console.error('API请求错误:', error.message);
        throw error; // 抛出错误供调用方处理
      }
    }
    
    // -------------------------- 使用示例 --------------------------
    // 1. GET请求示例(查询数据)
    async function testGet() {
      try {
        const data = await requestApi(
          'https://api.example.com/user/list', // 替换为实际接口地址
          'GET',
          { page: 1, size: 10, keyword: 'test' } // GET请求参数
        );
        console.log('GET请求成功:', data);
        // 业务逻辑处理...
      } catch (err) {
        alert('GET请求失败:' + err.message);
      }
    }
    
    // 2. POST请求示例(提交数据)
    async function testPost() {
      try {
        const data = await requestApi(
          'https://api.example.com/user/login', // 替换为实际接口地址
          'POST',
          { username: 'admin', password: '123456' } // POST请求体数据
        );
        console.log('POST请求成功:', data);
        // 业务逻辑处理...
      } catch (err) {
        alert('POST请求失败:' + err.message);
      }
    }
    
    // 执行请求(按需调用)
    // testGet();
    // testPost();
    
    
    import okhttp3.*;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.concurrent.TimeUnit;
    
    /**
     * Java 单文件实现GET/POST(JSON) API请求
     * 基于OkHttp和Jackson,复制后直接使用(需添加Maven/Gradle依赖)
     */
    public class ApiRequest {
        // 全局OkHttpClient实例(复用连接池)
        private static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder()
                .connectTimeout(10, TimeUnit.SECONDS)
                .readTimeout(10, TimeUnit.SECONDS)
                .writeTimeout(10, TimeUnit.SECONDS)
                .build();
    
        // Jackson JSON解析工具
        private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
    
        /**
         * GET请求方法
         * @param url 接口地址
         * @param params URL参数键值对
         * @return 接口响应字符串
         * @throws IOException 网络异常
         */
        public static String doGet(String url, Map params) throws IOException {
            HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
            if (params != null && !params.isEmpty()) {
                for (Map.Entry entry : params.entrySet()) {
                    urlBuilder.addQueryParameter(entry.getKey(), entry.getValue());
                }
            }
            Request request = new Request.Builder().url(urlBuilder.build()).get().build();
            try (Response response = OK_HTTP_CLIENT.newCall(request).execute()) {
                if (!response.isSuccessful()) {
                    throw new IOException("GET请求失败:" + response.code() + " " + response.message());
                }
                return response.body() != null ? response.body().string() : "";
            }
        }
    
        /**
         * POST(JSON)请求方法
         * @param url 接口地址
         * @param jsonStr JSON请求体字符串
         * @return 接口响应字符串
         * @throws IOException 网络异常
         */
        public static String doPostJson(String url, String jsonStr) throws IOException {
            MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
            RequestBody requestBody = RequestBody.create(mediaType, jsonStr);
            Request request = new Request.Builder().url(url).post(requestBody).build();
            try (Response response = OK_HTTP_CLIENT.newCall(request).execute()) {
                if (!response.isSuccessful()) {
                    throw new IOException("POST请求失败:" + response.code() + " " + response.message());
                }
                return response.body() != null ? response.body().string() : "";
            }
        }
    
        /**
         * 格式化JSON字符串(便于阅读)
         * @param jsonStr 原始JSON字符串
         * @return 格式化后的JSON
         * @throws IOException 解析异常
         */
        public static String formatJson(String jsonStr) throws IOException {
            if (jsonStr == null || jsonStr.isEmpty()) {
                return "";
            }
            Object jsonObj = OBJECT_MAPPER.readValue(jsonStr, Object.class);
            return OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObj);
        }
    
        // 主方法:测试GET/POST请求
        public static void main(String[] args) {
            try {
                // ------------------- 测试GET请求 -------------------
                String getUrl = "https://api.example.com/user/list"; // 替换为实际接口地址
                Map getParams = new HashMap<>();
                getParams.put("page", "1");
                getParams.put("size", "10");
                getParams.put("keyword", "test");
                String getResponse = doGet(getUrl, getParams);
                System.out.println("=== GET请求响应结果 ===");
                System.out.println(formatJson(getResponse));
    
                System.out.println("------------------------");
    
                // ------------------- 测试POST请求 -------------------
                String postUrl = "https://api.example.com/user/login"; // 替换为实际接口地址
                Map postData = new HashMap<>();
                postData.put("username", "admin");
                postData.put("password", "123456");
                String jsonStr = OBJECT_MAPPER.writeValueAsString(postData);
                String postResponse = doPostJson(postUrl, jsonStr);
                System.out.println("=== POST请求响应结果 ===");
                System.out.println(formatJson(postResponse));
    
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    
    
    package main
    
    import (
    	"bytes"
    	"encoding/json"
    	"fmt"
    	"io/ioutil"
    	"net/http"
    	"net/url"
    	"time"
    )
    
    // 全局HTTP客户端,设置超时时间
    var httpClient = &http.Client{
    	Timeout: 10 * time.Second, // 请求超时时间10秒
    }
    
    // DoGet 发送GET请求,自动拼接URL参数
    // urlStr: 接口地址
    // params: URL查询参数(键值对)
    // 返回:响应体字符串、错误信息
    func DoGet(urlStr string, params map[string]string) (string, error) {
    	// 解析基础URL
    	parsedUrl, err := url.Parse(urlStr)
    	if err != nil {
    		return "", fmt.Errorf("URL解析失败: %v", err)
    	}
    
    	// 拼接查询参数
    	query := parsedUrl.Query()
    	for key, value := range params {
    		query.Add(key, value)
    	}
    	parsedUrl.RawQuery = query.Encode()
    
    	// 发送GET请求
    	resp, err := httpClient.Get(parsedUrl.String())
    	if err != nil {
    		return "", fmt.Errorf("GET请求失败: %v", err)
    	}
    	defer resp.Body.Close() // 确保响应体关闭
    
    	// 检查响应状态码
    	if resp.StatusCode < 200 || resp.StatusCode >= 300 {
    		return "", fmt.Errorf("请求返回异常状态码: %d", resp.StatusCode)
    	}
    
    	// 读取响应体
    	body, err := ioutil.ReadAll(resp.Body)
    	if err != nil {
    		return "", fmt.Errorf("读取响应体失败: %v", err)
    	}
    
    	return string(body), nil
    }
    
    // DoPostJson 发送POST请求,JSON格式请求体
    // urlStr: 接口地址
    // data: 请求体数据(任意可序列化为JSON的结构体/Map)
    // 返回:响应体字符串、错误信息
    func DoPostJson(urlStr string, data interface{}) (string, error) {
    	// 将数据序列化为JSON字节流
    	jsonData, err := json.Marshal(data)
    	if err != nil {
    		return "", fmt.Errorf("JSON序列化失败: %v", err)
    	}
    
    	// 发送POST请求
    	resp, err := httpClient.Post(urlStr, "application/json", bytes.NewBuffer(jsonData))
    	if err != nil {
    		return "", fmt.Errorf("POST请求失败: %v", err)
    	}
    	defer resp.Body.Close()
    
    	// 检查响应状态码
    	if resp.StatusCode < 200 || resp.StatusCode >= 300 {
    		return "", fmt.Errorf("请求返回异常状态码: %d", resp.StatusCode)
    	}
    
    	// 读取响应体
    	body, err := ioutil.ReadAll(resp.Body)
    	if err != nil {
    		return "", fmt.Errorf("读取响应体失败: %v", err)
    	}
    
    	return string(body), nil
    }
    
    // FormatJson 格式化JSON字符串(便于控制台阅读)
    func FormatJson(jsonStr string) string {
    	var prettyJson bytes.Buffer
    	err := json.Indent(&prettyJson, []byte(jsonStr), "", "  ")
    	if err != nil {
    		return jsonStr // 格式化失败则返回原字符串
    	}
    	return prettyJson.String()
    }
    
    func main() {
    	// ------------------- 测试GET请求 -------------------
    	fmt.Println("=== 开始测试GET请求 ===")
    	getUrl := "https://api.example.com/user/list" // 替换为实际接口地址
    	getParams := map[string]string{
    		"page":    "1",
    		"size":    "10",
    		"keyword": "test",
    	}
    	getResp, err := DoGet(getUrl, getParams)
    	if err != nil {
    		fmt.Printf("GET请求出错: %v\n", err)
    	} else {
    		fmt.Println("GET请求响应结果:\n", FormatJson(getResp))
    	}
    
    	fmt.Println("------------------------")
    
    	// ------------------- 测试POST请求 -------------------
    	fmt.Println("=== 开始测试POST请求 ===")
    	postUrl := "https://api.example.com/user/login" // 替换为实际接口地址
    	// 定义POST请求体(可替换为自定义结构体)
    	postData := map[string]string{
    		"username": "admin",
    		"password": "123456",
    	}
    	postResp, err := DoPostJson(postUrl, postData)
    	if err != nil {
    		fmt.Printf("POST请求出错: %v\n", err)
    	} else {
    		fmt.Println("POST请求响应结果:\n", FormatJson(postResp))
    	}
    }
    
    
    import requests
    import json
    
    # 配置全局请求超时时间(单位:秒)
    TIMEOUT = 10
    
    def do_get(url: str, params: dict = None) -> str:
        """
        发送GET请求
        :param url: 接口地址
        :param params: URL查询参数(字典)
        :return: 响应体字符串(格式化后的JSON)
        :raises Exception: 请求失败时抛出异常
        """
        try:
            # 发送GET请求
            response = requests.get(url, params=params, timeout=TIMEOUT)
            # 检查响应状态码
            response.raise_for_status()
            # 返回格式化后的JSON字符串
            return json.dumps(response.json(), indent=2, ensure_ascii=False)
        except requests.exceptions.RequestException as e:
            raise Exception(f"GET请求失败: {str(e)}")
    
    def do_post_json(url: str, data: dict = None) -> str:
        """
        发送POST请求(JSON格式请求体)
        :param url: 接口地址
        :param data: JSON请求体(字典)
        :return: 响应体字符串(格式化后的JSON)
        :raises Exception: 请求失败时抛出异常
        """
        try:
            # 发送POST请求,自动设置Content-Type为application/json
            response = requests.post(url, json=data, timeout=TIMEOUT)
            # 检查响应状态码
            response.raise_for_status()
            # 返回格式化后的JSON字符串
            return json.dumps(response.json(), indent=2, ensure_ascii=False)
        except requests.exceptions.RequestException as e:
            raise Exception(f"POST请求失败: {str(e)}")
    
    if __name__ == "__main__":
        # ------------------- 测试GET请求 -------------------
        print("=== 开始测试GET请求 ===")
        get_url = "https://api.example.com/user/list"  # 替换为实际接口地址
        get_params = {
            "page": 1,
            "size": 10,
            "keyword": "test"
        }
        try:
            get_resp = do_get(get_url, get_params)
            print("GET请求响应结果:\n", get_resp)
        except Exception as e:
            print(e)
    
        print("-" * 40)
    
        # ------------------- 测试POST请求 -------------------
        print("=== 开始测试POST请求 ===")
        post_url = "https://api.example.com/user/login"  # 替换为实际接口地址
        post_data = {
            "username": "admin",
            "password": "123456"
        }
        try:
            post_resp = do_post_json(post_url, post_data)
            print("POST请求响应结果:\n", post_resp)
        except Exception as e:
            print(e)
    
    
    
    const http = require('http');
    const https = require('https');
    const querystring = require('querystring');
    
    /**
     * 通用请求函数(支持GET/POST,JSON格式)
     * @param {string} url - 接口完整地址
     * @param {string} method - GET/POST
     * @param {object} [data={}] - 请求参数(GET拼URL,POST为JSON体)
     * @returns {Promise} - 响应JSON数据
     */
    function requestApi(url, method, data = {}) {
      return new Promise((resolve, reject) => {
        // 解析URL
        const urlObj = new URL(url);
        const isHttps = urlObj.protocol === 'https:';
        const client = isHttps ? https : http;
    
        // 处理GET参数
        let path = urlObj.pathname;
        if (method.toUpperCase() === 'GET' && Object.keys(data).length > 0) {
          const params = querystring.stringify(data);
          path += (urlObj.search ? '&' : '?') + params;
        }
    
        // 处理POST请求体
        let postData = '';
        if (method.toUpperCase() === 'POST') {
          postData = JSON.stringify(data);
        }
    
        // 配置请求选项
        const options = {
          hostname: urlObj.hostname,
          port: urlObj.port || (isHttps ? 443 : 80),
          path: path + urlObj.search,
          method: method.toUpperCase(),
          headers: {
            'Content-Type': 'application/json; charset=utf-8',
            'Content-Length': Buffer.byteLength(postData)
          }
        };
    
        // 发送请求
        const req = client.request(options, (res) => {
          let rawData = '';
          res.on('data', (chunk) => { rawData += chunk; });
          res.on('end', () => {
            try {
              // 解析JSON响应
              const result = JSON.parse(rawData);
              resolve(result);
            } catch (err) {
              reject(new Error(`响应解析失败: ${err.message}`));
            }
          });
        });
    
        // 错误处理
        req.on('error', (err) => {
          reject(new Error(`请求失败: ${err.message}`));
        });
    
        // 写入POST请求体
        if (method.toUpperCase() === 'POST') {
          req.write(postData);
        }
        req.end();
      });
    }
    
    // 测试主函数
    async function main() {
      try {
        // ------------------- 测试GET请求 -------------------
        console.log('=== 开始测试GET请求 ===');
        const getUrl = 'https://api.example.com/user/list'; // 替换为实际接口
        const getParams = { page: 1, size: 10, keyword: 'test' };
        const getResult = await requestApi(getUrl, 'GET', getParams);
        console.log('GET请求响应:', JSON.stringify(getResult, null, 2));
    
        console.log('------------------------');
    
        // ------------------- 测试POST请求 -------------------
        console.log('=== 开始测试POST请求 ===');
        const postUrl = 'https://api.example.com/user/login'; // 替换为实际接口
        const postData = { username: 'admin', password: '123456' };
        const postResult = await requestApi(postUrl, 'POST', postData);
        console.log('POST请求响应:', JSON.stringify(postResult, null, 2));
      } catch (err) {
        console.error('请求出错:', err.message);
      }
    }
    
    // 执行测试
    main();
    
    
    
    #include 
    #include 
    #include 
    #include 
    
    // 定义缓冲区结构体,用于存储响应数据
    typedef struct {
        char* data;
        size_t size;
    } ResponseBuffer;
    
    // libcurl的写回调函数,将响应数据写入缓冲区
    static size_t write_callback(void* contents, size_t size, size_t nmemb, void* userp) {
        size_t realsize = size * nmemb;
        ResponseBuffer* buffer = (ResponseBuffer*)userp;
    
        // 重新分配内存存储响应数据
        char* temp = realloc(buffer->data, buffer->size + realsize + 1);
        if (temp == NULL) {
            fprintf(stderr, "内存分配失败!\n");
            return 0;
        }
        buffer->data = temp;
        memcpy(&(buffer->data[buffer->size]), contents, realsize);
        buffer->size += realsize;
        buffer->data[buffer->size] = '\0'; // 字符串结束符
    
        return realsize;
    }
    
    // 初始化响应缓冲区
    void init_buffer(ResponseBuffer* buffer) {
        buffer->data = malloc(1);
        buffer->size = 0;
    }
    
    // 释放响应缓冲区内存
    void free_buffer(ResponseBuffer* buffer) {
        free(buffer->data);
        buffer->data = NULL;
        buffer->size = 0;
    }
    
    /**
     * 发送GET请求
     * @param url 接口地址
     * @param params URL参数(格式:"key1=value1&key2=value2",传NULL则无参数)
     * @return 响应字符串(需手动free释放),失败返回NULL
     */
    char* http_get(const char* url, const char* params) {
        CURL* curl = curl_easy_init();
        if (!curl) {
            fprintf(stderr, "CURL初始化失败!\n");
            return NULL;
        }
    
        ResponseBuffer buffer;
        init_buffer(&buffer);
    
        // 拼接GET请求的URL和参数
        char* full_url = NULL;
        if (params && strlen(params) > 0) {
            full_url = (char*)malloc(strlen(url) + strlen(params) + 2);
            sprintf(full_url, "%s?%s", url, params);
        } else {
            full_url = (char*)malloc(strlen(url) + 1);
            strcpy(full_url, url);
        }
    
        // 设置CURL选项
        curl_easy_setopt(curl, CURLOPT_URL, full_url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L); // 超时时间10秒
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); // 跟随重定向
    
        // 执行GET请求
        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "GET请求失败: %s\n", curl_easy_strerror(res));
            free_buffer(&buffer);
            free(full_url);
            curl_easy_cleanup(curl);
            return NULL;
        }
    
        // 检查响应状态码
        long response_code;
        curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
        if (response_code < 200 || response_code >= 300) {
            fprintf(stderr, "GET请求返回异常状态码: %ld\n", response_code);
            free_buffer(&buffer);
            free(full_url);
            curl_easy_cleanup(curl);
            return NULL;
        }
    
        // 释放资源
        free(full_url);
        curl_easy_cleanup(curl);
    
        // 返回响应数据(需调用者手动free)
        return buffer.data;
    }
    
    /**
     * 发送POST请求(JSON格式请求体)
     * @param url 接口地址
     * @param json_data JSON请求体字符串
     * @return 响应字符串(需手动free释放),失败返回NULL
     */
    char* http_post_json(const char* url, const char* json_data) {
        CURL* curl = curl_easy_init();
        if (!curl) {
            fprintf(stderr, "CURL初始化失败!\n");
            return NULL;
        }
    
        ResponseBuffer buffer;
        init_buffer(&buffer);
    
        // 设置CURL选项
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L); // 超时时间10秒
        curl_easy_setopt(curl, CURLOPT_POST, 1L); // 启用POST请求
    
        // 设置JSON请求体和请求头
        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/json; charset=utf-8");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(json_data));
    
        // 执行POST请求
        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "POST请求失败: %s\n", curl_easy_strerror(res));
            free_buffer(&buffer);
            curl_slist_free_all(headers);
            curl_easy_cleanup(curl);
            return NULL;
        }
    
        // 检查响应状态码
        long response_code;
        curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
        if (response_code < 200 || response_code >= 300) {
            fprintf(stderr, "POST请求返回异常状态码: %ld\n", response_code);
            free_buffer(&buffer);
            curl_slist_free_all(headers);
            curl_easy_cleanup(curl);
            return NULL;
        }
    
        // 释放资源
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    
        // 返回响应数据(需调用者手动free)
        return buffer.data;
    }
    
    int main(void) {
        // 初始化libcurl
        curl_global_init(CURL_GLOBAL_ALL);
    
        // ------------------- 测试GET请求 -------------------
        printf("=== 开始测试GET请求 ===\n");
        const char* get_url = "https://api.example.com/user/list"; // 替换为实际接口
        const char* get_params = "page=1&size=10&keyword=test";   // GET参数
        char* get_resp = http_get(get_url, get_params);
        if (get_resp) {
            printf("GET请求响应结果:\n%s\n", get_resp);
            free(get_resp); // 释放响应内存
        }
    
        printf("------------------------\n");
    
        // ------------------- 测试POST请求 -------------------
        printf("=== 开始测试POST请求 ===\n");
        const char* post_url = "https://api.example.com/user/login"; // 替换为实际接口
        const char* post_json = "{\"username\":\"admin\",\"password\":\"123456\"}"; // JSON请求体
        char* post_resp = http_post_json(post_url, post_json);
        if (post_resp) {
            printf("POST请求响应结果:\n%s\n", post_resp);
            free(post_resp); // 释放响应内存
        }
    
        // 清理libcurl全局资源
        curl_global_cleanup();
        return 0;
    }
    
    
    
    #include 
    #include 
    #include 
    #include 
    
    // 响应数据缓冲区类,封装内存管理
    class ResponseBuffer {
    public:
        std::string data; // 存储响应数据的字符串,自动管理内存
    
        // libcurl写回调函数,将响应数据写入缓冲区
        static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
            size_t realSize = size * nmemb;
            ResponseBuffer* buffer = static_cast(userp);
            buffer->data.append(static_cast(contents), realSize);
            return realSize;
        }
    };
    
    // HTTP请求工具类,封装GET/POST(JSON)方法
    class HttpRequester {
    private:
        CURL* curl; // CURL句柄
        long timeout; // 请求超时时间(秒)
    
    public:
        // 构造函数:初始化CURL
        HttpRequester(long timeout = 10) : timeout(timeout) {
            curl_global_init(CURL_GLOBAL_ALL);
            curl = curl_easy_init();
            if (!curl) {
                throw std::runtime_error("CURL初始化失败!");
            }
            // 设置全局超时
            curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
            // 跟随HTTP重定向
            curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
        }
    
        // 析构函数:释放CURL资源
        ~HttpRequester() {
            if (curl) {
                curl_easy_cleanup(curl);
            }
            curl_global_cleanup();
        }
    
        // 禁用拷贝构造和赋值,避免资源重复释放
        HttpRequester(const HttpRequester&) = delete;
        HttpRequester& operator=(const HttpRequester&) = delete;
    
        /**
         * 发送GET请求
         * @param url 接口地址
         * @param params URL参数(格式:"key1=value1&key2=value2")
         * @return 响应字符串
         * @throws std::runtime_error 请求失败时抛出异常
         */
        std::string Get(const std::string& url, const std::string& params = "") {
            if (!curl) {
                throw std::runtime_error("CURL句柄未初始化");
            }
    
            // 拼接完整URL(带参数)
            std::string fullUrl = url;
            if (!params.empty()) {
                fullUrl += "?" + params;
            }
    
            ResponseBuffer buffer;
            // 设置CURL选项
            curl_easy_setopt(curl, CURLOPT_URL, fullUrl.c_str());
            curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ResponseBuffer::WriteCallback);
            curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
    
            // 执行GET请求
            CURLcode res = curl_easy_perform(curl);
            if (res != CURLE_OK) {
                throw std::runtime_error("GET请求失败: " + std::string(curl_easy_strerror(res)));
            }
    
            // 检查响应状态码
            long responseCode;
            curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode);
            if (responseCode < 200 || responseCode >= 300) {
                throw std::runtime_error("GET请求返回异常状态码: " + std::to_string(responseCode));
            }
    
            return buffer.data;
        }
    
        /**
         * 发送POST请求(JSON格式请求体)
         * @param url 接口地址
         * @param jsonData JSON请求体字符串
         * @return 响应字符串
         * @throws std::runtime_error 请求失败时抛出异常
         */
        std::string PostJson(const std::string& url, const std::string& jsonData) {
            if (!curl) {
                throw std::runtime_error("CURL句柄未初始化");
            }
    
            ResponseBuffer buffer;
            // 设置POST请求基础选项
            curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
            curl_easy_setopt(curl, CURLOPT_POST, 1L); // 启用POST方法
            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, jsonData.c_str()); // 设置请求体
            curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, jsonData.length()); // 设置请求体长度
            curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ResponseBuffer::WriteCallback);
            curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
    
            // 设置JSON请求头
            struct curl_slist* headers = nullptr;
            headers = curl_slist_append(headers, "Content-Type: application/json; charset=utf-8");
            curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    
            // 执行POST请求
            CURLcode res = curl_easy_perform(curl);
            // 释放请求头链表(无论请求成功与否都要释放)
            curl_slist_free_all(headers);
    
            if (res != CURLE_OK) {
                throw std::runtime_error("POST请求失败: " + std::string(curl_easy_strerror(res)));
            }
    
            // 检查响应状态码
            long responseCode;
            curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode);
            if (responseCode < 200 || responseCode >= 300) {
                throw std::runtime_error("POST请求返回异常状态码: " + std::to_string(responseCode));
            }
    
            return buffer.data;
        }
    };
    
    // 主函数:测试GET/POST请求
    int main() {
        try {
            // 创建HTTP请求器实例
            HttpRequester requester;
    
            // ------------------- 测试GET请求 -------------------
            std::cout << "=== 开始测试GET请求 ===" << std::endl;
            std::string getUrl = "https://api.example.com/user/list"; // 替换为实际接口
            std::string getParams = "page=1&size=10&keyword=test";   // GET参数
            std::string getResp = requester.Get(getUrl, getParams);
            std::cout << "GET请求响应结果:\n" << getResp << std::endl;
    
            std::cout << "------------------------" << std::endl;
    
            // ------------------- 测试POST请求 -------------------
            std::cout << "=== 开始测试POST请求 ===" << std::endl;
            std::string postUrl = "https://api.example.com/user/login"; // 替换为实际接口
            std::string postJson = R"({"username":"admin","password":"123456"})"; // JSON请求体(原生字符串避免转义)
            std::string postResp = requester.PostJson(postUrl, postJson);
            std::cout << "POST请求响应结果:\n" << postResp << std::endl;
    
        } catch (const std::exception& e) {
            // 捕获所有异常并打印
            std::cerr << "请求出错: " << e.what() << std::endl;
            return 1;
        }
    
        return 0;
    }
    
    
    
    using System;
    using System.Net.Http;
    using System.Text;
    using System.Threading.Tasks;
    using System.Text.Json;
    
    /// 
    /// HTTP请求工具类,封装GET/POST(JSON)请求
    /// 
    public class HttpRequester
    {
        // 静态HttpClient实例(推荐单例使用,避免频繁创建释放连接)
        private static readonly HttpClient _httpClient = new HttpClient
        {
            Timeout = TimeSpan.FromSeconds(10) // 设置10秒超时
        };
    
        /// 
        /// 发送GET请求
        /// 
        /// 接口完整地址
        /// URL查询参数(键值对)
        /// 格式化后的JSON响应字符串
        /// 请求失败时抛出异常
        public static async Task GetAsync(string url, System.Collections.Generic.Dictionary paramsDict = null)
        {
            // 拼接查询参数
            if (paramsDict != null && paramsDict.Count > 0)
            {
                var queryBuilder = new System.Text.StringBuilder();
                foreach (var pair in paramsDict)
                {
                    queryBuilder.Append($"{Uri.EscapeDataString(pair.Key)}={Uri.EscapeDataString(pair.Value)}&");
                }
                string query = queryBuilder.ToString().TrimEnd('&');
                url += $"{(url.Contains("?") ? "&" : "?")}{query}";
            }
    
            // 发送GET请求
            using var response = await _httpClient.GetAsync(url);
            // 检查响应状态码,非2xx则抛出异常
            response.EnsureSuccessStatusCode();
    
            // 读取响应并格式化JSON
            string jsonResponse = await response.Content.ReadAsStringAsync();
            return FormatJson(jsonResponse);
        }
    
        /// 
        /// 发送POST请求(JSON格式请求体)
        /// 
        /// 接口完整地址
        /// 请求体数据(任意可序列化的对象)
        /// 格式化后的JSON响应字符串
        /// 请求失败时抛出异常
        public static async Task PostJsonAsync(string url, T data)
        {
            // 将对象序列化为JSON字符串
            string jsonData = JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = false });
            // 构造JSON请求体
            using var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
            // 发送POST请求
            using var response = await _httpClient.PostAsync(url, content);
            // 检查响应状态码
            response.EnsureSuccessStatusCode();
    
            // 读取响应并格式化JSON
            string jsonResponse = await response.Content.ReadAsStringAsync();
            return FormatJson(jsonResponse);
        }
    
        /// 
        /// 格式化JSON字符串(便于阅读)
        /// 
        private static string FormatJson(string json)
        {
            if (string.IsNullOrEmpty(json)) return json;
            var jsonDoc = JsonDocument.Parse(json);
            return JsonSerializer.Serialize(jsonDoc, new JsonSerializerOptions { WriteIndented = true });
        }
    }
    
    /// 
    /// 测试类,包含主函数
    /// 
    class Program
    {
        // C# 7.1+支持Main方法为async
        static async Task Main(string[] args)
        {
            try
            {
                // ------------------- 测试GET请求 -------------------
                Console.WriteLine("=== 开始测试GET请求 ===");
                string getUrl = "https://api.example.com/user/list"; // 替换为实际接口
                var getParams = new System.Collections.Generic.Dictionary
                {
                    { "page", "1" },
                    { "size", "10" },
                    { "keyword", "test" }
                };
                string getResponse = await HttpRequester.GetAsync(getUrl, getParams);
                Console.WriteLine("GET请求响应结果:\n" + getResponse);
    
                Console.WriteLine("------------------------");
    
                // ------------------- 测试POST请求 -------------------
                Console.WriteLine("=== 开始测试POST请求 ===");
                string postUrl = "https://api.example.com/user/login"; // 替换为实际接口
                // 定义请求体对象(可替换为自定义类)
                var postData = new
                {
                    username = "admin",
                    password = "123456"
                };
                string postResponse = await HttpRequester.PostJsonAsync(postUrl, postData);
                Console.WriteLine("POST请求响应结果:\n" + postResponse);
            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine($"请求失败: {ex.Message}");
                if (ex.InnerException != null)
                {
                    Console.WriteLine($"内部异常: {ex.InnerException.Message}");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"程序异常: {ex.Message}");
            }
    
            // 防止控制台立即关闭
            Console.WriteLine("\n按任意键退出...");
            Console.ReadKey();
        }
    }
    
    
    
    ' 引入必要的命名空间
    Imports System
    Imports System.Net.Http
    Imports System.Text
    Imports System.Threading.Tasks
    Imports System.Collections.Generic
    Imports System.Text.Json
    Imports System.Net.Http.Headers
    
    ''' 
    ''' HTTP请求工具类,封装GET/POST(JSON)核心逻辑
    ''' 基于.NET内置HttpClient,支持异步请求、JSON序列化/反序列化
    ''' 
    Public Class HttpHelper
        ' 静态HttpClient单例(推荐单例使用,避免端口耗尽)
        Private Shared ReadOnly _httpClient As New HttpClient With {
            .Timeout = TimeSpan.FromSeconds(10) ' 设置10秒请求超时
        }
    
        ''' 
        ''' 发送GET请求,自动拼接URL参数
        ''' 
        ''' 接口基础地址
        ''' URL查询参数(键值对)
        ''' 格式化后的JSON响应字符串
        Public Shared Async Function SendGetRequestAsync(baseUrl As String, Optional parameters As Dictionary(Of String, String) = Nothing) As Task(Of String)
            Try
                ' 拼接查询参数
                Dim requestUrl As String = baseUrl
                If parameters IsNot Nothing AndAlso parameters.Count > 0 Then
                    Dim queryBuilder As New StringBuilder()
                    For Each pair In parameters
                        queryBuilder.Append($"{Uri.EscapeDataString(pair.Key)}={Uri.EscapeDataString(pair.Value)}&")
                    Next
                    Dim query As String = queryBuilder.ToString().TrimEnd("&"c)
                    requestUrl &= If(requestUrl.Contains("?"), "&", "?") & query
                End If
    
                ' 发送GET请求并验证状态码
                Dim response As HttpResponseMessage = Await _httpClient.GetAsync(requestUrl)
                response.EnsureSuccessStatusCode()
    
                ' 读取响应并格式化JSON
                Dim responseJson As String = Await response.Content.ReadAsStringAsync()
                Return FormatJsonString(responseJson)
            Catch ex As HttpRequestException
                Throw New Exception($"GET请求失败:{ex.Message}", ex)
            End Try
        End Function
    
        ''' 
        ''' 发送POST请求(JSON格式请求体)
        ''' 
        ''' 请求体数据类型
        ''' 接口完整地址
        ''' 请求体数据(任意可序列化对象)
        ''' 格式化后的JSON响应字符串
        Public Shared Async Function SendPostJsonRequestAsync(Of T)(apiUrl As String, requestData As T) As Task(Of String)
            Try
                ' 将对象序列化为JSON字符串
                Dim jsonBody As String = JsonSerializer.Serialize(requestData, New JsonSerializerOptions With {.WriteIndented = False})
                ' 构造JSON请求体
                Dim content As New StringContent(jsonBody, Encoding.UTF8, "application/json")
    
                ' 发送POST请求并验证状态码
                Dim response As HttpResponseMessage = Await _httpClient.PostAsync(apiUrl, content)
                response.EnsureSuccessStatusCode()
    
                ' 读取响应并格式化JSON
                Dim responseJson As String = Await response.Content.ReadAsStringAsync()
                Return FormatJsonString(responseJson)
            Catch ex As HttpRequestException
                Throw New Exception($"POST请求失败:{ex.Message}", ex)
            End Try
        End Function
    
        ''' 
        ''' 添加全局请求头(如Token、API Key)
        ''' 
        ''' 请求头名称
        ''' 请求头值
        Public Shared Sub AddGlobalHeader(headerName As String, headerValue As String)
            If Not _httpClient.DefaultRequestHeaders.Contains(headerName) Then
                _httpClient.DefaultRequestHeaders.Add(headerName, headerValue)
            End If
        End Sub
    
        ''' 
        ''' 格式化JSON字符串,提升可读性
        ''' 
        ''' 原始JSON字符串
        ''' 格式化后的JSON
        Private Shared Function FormatJsonString(rawJson As String) As String
            If String.IsNullOrEmpty(rawJson) Then Return rawJson
            Dim jsonDoc As JsonDocument = JsonDocument.Parse(rawJson)
            Return JsonSerializer.Serialize(jsonDoc, New JsonSerializerOptions With {.WriteIndented = True})
        End Function
    End Class
    
    ''' 
    ''' 测试程序入口,演示GET/POST请求的使用
    ''' 
    Module Program
        ' VB.NET主函数,异步执行测试逻辑
        Sub Main()
            ' 同步等待异步方法执行(控制台程序专用)
            TestApiRequestsAsync().GetAwaiter().GetResult()
            ' 防止控制台立即关闭
            Console.WriteLine(vbCrLf & "按任意键退出程序...")
            Console.ReadKey()
        End Sub
    
        ''' 
        ''' 测试GET和POST API请求
        ''' 
        Private Async Function TestApiRequestsAsync() As Task
            Try
                ' 可选:添加全局请求头(如Token认证)
                ' HttpHelper.AddGlobalHeader("Authorization", "Bearer your_token_here")
                ' HttpHelper.AddGlobalHeader("X-API-Key", "your_api_key_here")
    
                ' ------------------- 测试GET请求 -------------------
                Console.WriteLine("=== 开始执行GET请求 ===")
                Dim getUrl As String = "https://api.example.com/user/list" ' 替换为实际接口地址
                Dim getParams As New Dictionary(Of String, String) From {
                    {"page", "1"},
                    {"size", "10"},
                    {"keyword", "vb.net_test"}
                }
                Dim getResponse As String = Await HttpHelper.SendGetRequestAsync(getUrl, getParams)
                Console.WriteLine("GET请求响应结果:" & vbCrLf & getResponse)
    
                Console.WriteLine("------------------------")
    
                ' ------------------- 测试POST请求 -------------------
                Console.WriteLine("=== 开始执行POST请求 ===")
                Dim postUrl As String = "https://api.example.com/user/login" ' 替换为实际接口地址
                ' 匿名类型请求体(也可替换为自定义实体类)
                Dim postData = New With {
                    .username = "vbnet_admin",
                    .password = "123456_test",
                    .rememberMe = True
                }
                Dim postResponse As String = Await HttpHelper.SendPostJsonRequestAsync(postUrl, postData)
                Console.WriteLine("POST请求响应结果:" & vbCrLf & postResponse)
    
            Catch ex As Exception
                Console.WriteLine($"请求异常:{ex.Message}")
                If ex.InnerException IsNot Nothing Then
                    Console.WriteLine($"内部异常详情:{ex.InnerException.Message}")
                End If
            End Try
        End Function
    End Module
    
    
    本工具支持 API 接口的实时请求测试,实时返回接口响应结果,助力开发者快速排查接口问题。
    ⚠️ 本工具为真实请求,将消耗额度 / 产生计费,请勿填写私密信息。
    ⚠️ 本页面工具将自动添加请求头,无需手动添加。
    请求参数
    参数名 参数值 操作

    仅需三步即可快速接入

    1
    注册认证 · 获取密钥

    注册开发者账号并完成实名认证,在 控制台 申请专属API密钥(支持多种安全认证策略)。

    2
    接口调试 · 开发集成

    使用平台 在线调试工具 快速验证接口,通过官方API文档完成业务系统的接口集成与联调。

    3
    生产上线 · 监控运维

    在生产环境调用接口,然后在 个人中心 查看调用日志、平台提供弹性配额与故障排查支持。