数字化时代,信息安全如同金盾,而身份验证则是这面盾牌的核心环节。每一次登录的背后,都是您对隐私保护的渴望;每一次交易的信任,都源于对身份真实性的确认。现如今,随着网络平台的不断增多,实名认证接口的需求也在不断提升。
以下是Java语言调用翔云身份实名认证API的代码:
package com.test;
import okhttp3.;
import org.json.JSONObject;
import java.io.;
/**
- 需要添加依赖
-
com.squareup.okhttp3
-
okhttp
-
4.12.0
*/
class Sample {
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
public static void main(String []args) throws IOException{
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("img","/9j")
.addFormDataPart("key","M***********g")
.addFormDataPart("secret","3***********6")
.addFormDataPart("trueName","陈**")
.addFormDataPart("idenNo","13***************3")
.addFormDataPart("typeId","3003")
.addFormDataPart("format","json")
.build();
Request request = new Request.Builder()
.url("https://netocr.com/verapi/veriden.do")
.method("POST", body)
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
System.out.println(response.body().string());
}
}
标签:Java,addFormDataPart,接口,认证,实名,new From: https://www.cnblogs.com/netocr/p/18070942