开始操作前请提前准备好以下所有物料,避免中途卡壳:
所有对接必须先申请官方接口权限,未申请的接口调用会直接返回403:
审核周期为3个工作日,审核通过后系统会自动生成唯一的appKey和appSecret,appSecret仅展示1次,请立即保存到本地加密存储。
生产环境接口地址:https://tsm.miit.gov.cn/dxxzsp/api/edi/verify

测试环境接口地址:https://tsm.miit.gov.cn/dxxzsp/test/api/edi/verify
请求方式:POST,请求头必须携带以下参数:
请求体JSON格式(可直接复制修改):
```json { "licenseNo": "你的EDI许可证号", "creditCode": "企业统一社会信用代码", "domain": "档案管理系统备案域名" } ```Java版(基于OkHttp3):
```java import okhttp3.; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.util.Formatter; public class EdiVerifyDemo { // 替换为自己的appKey和appSecret private static final String APP_KEY = "xxxxxx"; private static final String APP_SECRET = "xxxxxx"; private static final String PROD_URL = "https://tsm.miit.gov.cn/dxxzsp/api/edi/verify"; public static void main(String[] args) throws Exception { long timestamp = System.currentTimeMillis(); String requestBody = "{\"licenseNo\":\"你的EDI许可证号\",\"creditCode\":\"企业统一社会信用代码\",\"domain\":\"你的档案系统域名\"}"; String sign = generateSign(APP_KEY + timestamp + requestBody, APP_SECRET); OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, requestBody); Request request = new Request.Builder() .url(PROD_URL) .post(body) .addHeader("appKey", APP_KEY) .addHeader("timestamp", String.valueOf(timestamp)) .addHeader("sign", sign) .addHeader("Content-Type", "application/json") .build(); Response response = client.newCall(request).execute(); System.out.println(response.body().string()); } private static String generateSign(String data, String secret) throws Exception { Mac mac = Mac.getInstance("HmacSHA256"); SecretKeySpec secretKeySpec = new SecretKeySpec(secret.getBytes(), "HmacSHA256"); mac.init(secretKeySpec); byte[] bytes = mac.doFinal(data.getBytes()); Formatter formatter = new Formatter(); for (byte b : bytes) { formatter.format("%02x", b); } return formatter.toString(); } } ```Node.js版(基于Axios):
```javascript const axios = require('axios'); const crypto = require('crypto'); // 替换为自己的appKey和appSecret const APP_KEY = 'xxxxxx'; const APP_SECRET = 'xxxxxx'; const PROD_URL = 'https://tsm.miit.gov.cn/dxxzsp/api/edi/verify'; const generateSign = (data, secret) => { return crypto.createHmac('sha256', secret).update(data).digest('hex'); } const verifyEdi = async () => { const timestamp = Date.now(); const requestBody = { licenseNo: '你的EDI许可证号', creditCode: '企业统一社会信用代码', domain: '你的档案系统域名' }; const sign = generateSign(APP_KEY + timestamp + JSON.stringify(requestBody), APP_SECRET); const headers = { appKey: APP_KEY, timestamp: timestamp, sign: sign, 'Content-Type': 'application/json' }; const res = await axios.post(PROD_URL, requestBody, { headers }); console.log(res.data); } verifyEdi(); ```