本文为您提供了Java语言版本的提交查询接口对接DEMO示例
//测试ok by zero 2025-07-24
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
public class test
{
public static void main(String args[])
{
String url = "https://api.ihuyi.com/idcard/entcert/Submit.json";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
HashMap<String, String> bodyArr = new HashMap<>();
bodyArr.put("account", "xxxxxxxx"); //APIID(用户中心【认证核验】-【企业信息验证】-【产品总览】查看)
bodyArr.put("password", "xxxxxxxxx"); //1、APIKEY(用户中心【认证核验】-【企业信息验证】-【产品总览】查看)
2、动态密码(生成动态密码方式请看该文档末尾的说明)
bodyArr.put("ent_name", "上海************有限公司"); //企业名称(ent_name、ent_code、organization_code、reg_no四选一传递)
bodyArr.put("ent_code", "913******"); //社会信用代码(ent_name、ent_code、organization_code、reg_no四选一传递)
bodyArr.put("organization_code", "403925******"); //组织机构代码(ent_name、ent_code、organization_code、reg_no四选一传递)
bodyArr.put("reg_no", "403925******"); //注册号(ent_name、ent_code、organization_code、reg_no四选一传递)
bodyArr.put("license_name_list", "1"); //证书类型列表(参考附件《证书类型》),多个用英文逗号分隔
bodyArr.put("have_history", "1"); //是否包含历史资质证书(1-包含;0-不包含;默认包含)。历史资质证书指过期、注销等状态的证
bodyArr.put("page_index", "1"); //页码,默认第一页
bodyArr.put("page_size", "50"); //每页条数(默认50条,最大50条)
bodyArr.put("time", "1623643787"); //Unix时间戳(10位整型数字,当使用动态密码方式时为必填)
String queryString = convertToQueryString(bodyArr);
try {
Map<String, Object> response = sendRequest(url, headers, queryString, "POST");
// 打印响应
System.out.printf("状态码: %s%n", response.get("status"));
System.out.printf("响应内容: %s%n", response.get("body"));
} catch (Exception e) {
e.printStackTrace();
}
}
public static Map<String, Object> sendRequest(String url, Map<String, String> headers, String queryString, String method) throws Exception {
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create(url))
.method(method, queryString.isEmpty() ?
HttpRequest.BodyPublishers.noBody() :
HttpRequest.BodyPublishers.ofString(queryString, StandardCharsets.UTF_8));
headers.forEach(requestBuilder::header);
HttpClient httpClient = HttpClient.newBuilder().build();
HttpResponse<String> response = httpClient.send(
requestBuilder.build(),
HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)
);
Map<String, Object> result = new HashMap<>();
result.put("status", response.statusCode());
result.put("body", response.body());
return result;
}
public static String convertToQueryString(HashMap<String, String> map) {
StringBuilder queryString = new StringBuilder();
for (Map.Entry<String, String> entry : map.entrySet()) {
String encodedKey = URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8);
String encodedValue = URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8);
if (queryString.length() > 0) {
queryString.append("&");
}
queryString.append(encodedKey).append("=").append(encodedValue);
}
return queryString.toString();
}
}
国内专业互联网团队
21年行业经验
7x24小时售后支持
丰富的行业经验
Copyright © 2004-2025 上海思锐信息技术有限公司 All rights reserved. 沪ICP备07035915号-15 电信增值业务许可证:B2-20160082
服务热线:
4008 808 898
服务热线(工作时间):
4008 808 898
业务咨询(非工作时间):
售后咨询(非工作时间):