本文為您提供了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/veh/nat5conf/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(用戶中心【認(rèn)證核驗(yàn)】-【車輛與道路運(yùn)輸信息驗(yàn)證】-【產(chǎn)品總覽】查看)
bodyArr.put("password", "xxxxxxxxx"); //1、APIKEY(用戶中心【認(rèn)證核驗(yàn)】-【車輛與道路運(yùn)輸信息驗(yàn)證】-【產(chǎn)品總覽】查看)
2、動態(tài)密碼(生成動態(tài)密碼方式請看該文檔末尾的說明)
bodyArr.put("car_no", "滬A12345"); //車牌號
bodyArr.put("car_type", "11"); //車輛類型(01:大型汽車;02:小型汽車;51:新能源大型車;52:新能源小型車;03:使館汽車;04:領(lǐng)館汽車;05:境外汽車;06:外籍汽車;07:普通摩托車;08:輕便摩托車;09:使館摩托車;10:領(lǐng)館摩托車;11:境外摩托車;12:外籍摩托車;13:低速車;14:拖拉機(jī);15:掛車;16:教練汽車;17:教練摩托車;20:臨時(shí)入境汽車;21:臨時(shí)入境摩托車;22:臨時(shí)行駛車;23:警用汽車;24:警用摩托車;25:原農(nóng)機(jī)號牌;26:香港入出境車;27:澳門入出境車;99:其他,不填默認(rèn)為普通乘用車02)
bodyArr.put("time", "1623643787"); //Unix時(shí)間戳(10位整型數(shù)字,當(dāng)使用動態(tài)密碼方式時(shí)為必填)
String queryString = convertToQueryString(bodyArr);
try {
Map<String, Object> response = sendRequest(url, headers, queryString, "POST");
// 打印響應(yīng)
System.out.printf("狀態(tài)碼: %s%n", response.get("status"));
System.out.printf("響應(yīng)內(nèi)容: %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();
}
}
國內(nèi)專業(yè)互聯(lián)網(wǎng)團(tuán)隊(duì)
21年行業(yè)經(jīng)驗(yàn)
7x24小時(shí)售后支持
豐富的行業(yè)經(jīng)驗(yàn)
互 億 無 線 官 方 微 信 號
Copyright ? 2004-2025 上海思銳信息技術(shù)有限公司 All rights reserved. 滬ICP備07035915號-15 電信增值業(yè)務(wù)許可證:B2-20160082
服務(wù)熱線:
4008 808 898
服務(wù)熱線(工作時(shí)間):
4008 808 898
業(yè)務(wù)咨詢(非工作時(shí)間):
售后咨詢(非工作時(shí)間):
驗(yàn)證碼已發(fā)送到您的手機(jī),請查收!
輸入驗(yàn)證碼后,點(diǎn)擊“開通體驗(yàn)賬戶”按鈕可立即開通體驗(yàn)賬戶。