Files
huang 93200a9074
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m57s
开放接口完成
2026-05-11 14:26:10 +08:00

62 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 代理开放接口第三方对接示例
本目录是按 Apifox 文档实现的第三方调用示例,不依赖当前项目内部包。
## 默认配置
- 服务地址:`https://cmp-api.boss160.cn`
- 账号:`15571055000`
- 密码:`Admin@123456`
也可以通过环境变量覆盖:
```bash
AGENT_OPEN_API_BASE_URL=https://cmp-api.boss160.cn \
AGENT_OPEN_API_ACCOUNT=15571055000 \
AGENT_OPEN_API_PASSWORD='Admin@123456' \
go run ./tests/agent_open_api -action wallet-balance
```
## 支持的 action
```bash
# 查询预充值钱包余额
go run ./tests/agent_open_api -action wallet-balance
# 查询套餐列表
go run ./tests/agent_open_api -action packages -page 1 -page-size 20
# 查询单卡实名状态
go run ./tests/agent_open_api -action realname-status -card-no <ICCID或虚拟号或MSISDN>
# 查询单卡状态
go run ./tests/agent_open_api -action card-status -card-no <ICCID或虚拟号或MSISDN>
# 查询单卡流量
go run ./tests/agent_open_api -action card-traffic -card-no <ICCID或虚拟号或MSISDN>
# 查询预充值钱包流水
go run ./tests/agent_open_api -action wallet-transactions -page 1 -page-size 20
# 钱包套餐购买,会真实创建订单,必须显式传入该 action
go run ./tests/agent_open_api -action package-order -card-nos <卡1,卡2> -package-code <套餐编码>
```
## 签名规则
每个请求携带 `X-Agent-Account``X-Agent-Password``X-Agent-Timestamp``X-Agent-Nonce``X-Agent-Sign`
签名原文按以下 7 行拼接,最后一行后不追加换行:
```text
METHOD
PATH
canonical_query
body_sha256
timestamp
nonce
account
```
`canonical_query` 会排除 `sign` 参数,参数名升序,同名多值按值升序,并使用 URL QueryEscape 编码。`body_sha256` 使用最终发送请求体字节计算GET 和空 body 使用空字符串的 SHA256。