Files
iotlcm/docs/openapi/legacy/index.md
T
2026-10-29 15:45:46 +08:00

134 lines
3.8 KiB
Markdown
Raw 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.
---
title: 概览与鉴权
description: iotLCM 旧版兼容接口概览与鉴权说明
outline: deep
---
# 概览与鉴权
本文档收录历史 `/route/open/*` 路径下仍在维护的兼容接口。鉴权通过请求体 `verify` 中的 `appId`、`password` 和 `timeStamp` 完成;`sign` 为历史兼容字段,当前服务不校验。
这些接口由 iotLCM OpenAPI 服务实现并提供,与 V3 接口同域(`api.example.com`),仅请求路径与鉴权方式不同。
## 服务地址
```text
https://api.example.com
```
完整请求 URL:
```text
https://api.example.com/route/open/{接口名}
```
## 统一鉴权
以下各接口的“请求示例”均为完整 JSON 请求体,调用时请设置 `Content-Type: application/json`;`verify.sign` 可传空字符串 `""`。
所有接口通过请求体 `verify` 字段鉴权:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| appId | string | 用于唯一标识请求 |
| password | string | 密码 |
| timeStamp | string | 时间戳,`"" + System.currentTimeMillis()` |
| sign | string | 当前服务不校验,可传空字符串 `""`。 |
### 历史签名规则(仅供参考)
当前服务不要求计算签名,也无需提供 `accessKey`。以下为历史客户端示例中的签名算法,仅供维护已有签名逻辑时参考。
```text
appId={appId}&password={password}&timeStamp={timeStamp}&key={accessKey}
```
对拼接后的字符串计算 MD5,并将结果转为大写,即为 `sign`。`sign` 不参与签名计算;`accessKey` 仅用于签名,不放入请求体的 `verify` 字段。
## 统一返回结构
```json
{
"status": 0,
"message": "",
"result": {}
}
```
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| status | number | 业务状态码,成功为 `0` |
| message | string | 错误或提示信息 |
| result | any | 业务数据 |
## 公共字典
卡状态编码(适用于 `cardInfo`、`simStatus`、`queryCardInfoList` 响应中的 `statusId` / `statusCode` / `status`):
| 编码 | 说明 |
| --- | --- |
| 1 | 库存 |
| 2 | 可测试 |
| 3 | 待激活 |
| 4 | 已激活 |
| 5 | 已停机 |
| 6 | 预销户 |
| 7 | 已销户 |
| 8 | 未知 |
## 请求案例
以下为历史 Java 示例,保留原有 `verify` 块与 `sign` 的生成方式供参考。调用当前服务时,可直接设置 `verify.sign` 为 `""`,省略签名计算。
```java
// 服务器请求地址
protected static String server_Ip = "https://api.example.com/route/open";
// appId
public static String appId = null;
// 密钥密码
public static String password = null;
/**
* Sign 加密类
*/
public static String getSign(Map<String, Object> map, String key) {
List<String> list = new ArrayList<>(map.keySet());
Collections.sort(list);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
String k = list.get(i);
String v = (String) map.get(k);
sb.append(k).append("=").append(v).append("&");
}
String signstr = sb.append("key=").append(key).toString();
String sign = MD5Util.MD5Encode(signstr).toUpperCase();
return sign;
}
public static void main(String[] args) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> parmap = new HashMap<>();
Map<String, Object> verify = new HashMap<>();
String appId = "test";
String password = "uhbhkh223123";
String accessKey = "1234567896132";
String timeStamp = "" + System.currentTimeMillis();
verify.put("password", password);
verify.put("appId", appId);
verify.put("timeStamp", timeStamp);
verify.put("sign", getSign(verify, accessKey));
parmap.put("type", "iccid");
parmap.put("cardno", "89860400000000002135");
map.put("verify", verify);
map.put("Param", parmap);
server_Ip += "/cardInfo";
String result = HttpUtil.post(server_Ip, JSON.toJSONString(map));
System.out.println(result);
}
```