1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 如何对用户绑定的身份证真实性进行实名认证API接口(java)

如何对用户绑定的身份证真实性进行实名认证API接口(java)

时间:2023-03-06 19:21:46

相关推荐

如何对用户绑定的身份证真实性进行实名认证API接口(java)

现在随着对用户实名制的要求,因此用户提交的身份证信息经查需要检查是否为真实信息,我们需要对用户提交的身份证信息进行核验,具体操作步骤如下:

第一步

到认证平台注册账号:云亿互通--实名认证服务 (),然后即可获取秘钥。

第二步

调试程序,下面依据java为例:

import net.sf.json.JSONObject;import org.apache.http.HttpEntity;import org.apache.http.NameValuePair;import org.apache.http.client.ClientProtocolException;import org.apache.http.client.entity.UrlEncodedFormEntity;import org.apache.http.client.methods.CloseableHttpResponse;import org.apache.http.client.methods.HttpPost;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.http.impl.client.HttpClients;import org.apache.http.message.BasicNameValuePair;import org.apache.http.util.EntityUtils;import gate.util.MD5;// 公民身份证实名认证实例代码public class IDTest {public static void main(String[] args) {// 创建默认的httpClient实例CloseableHttpClient httpclient = HttpClients.createDefault();HttpPost httppost = new HttpPost("/idAuthentic");// 创建参数队列String merNo = "26001";String name = "张三";String idNo = "350783199806195231";String md5Key = "12345678"; // 在【管理后台-->安全管理-->秘钥信息】里面获取String MD5Info = "";MD5 md5 = new MD5();String signStr = "merNo=" + merNo + "&name=" + name + "&idNo=" + idNo + "&" + md5Key;MD5Info = md5.getMD5Info(signStr);List<NameValuePair> formparams = new ArrayList<NameValuePair>();formparams.add(new BasicNameValuePair("merNo", merNo));formparams.add(new BasicNameValuePair("name", name));formparams.add(new BasicNameValuePair("idNo", idNo));formparams.add(new BasicNameValuePair("MD5Info", MD5Info));UrlEncodedFormEntity uefEntity;try {uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8");httppost.setEntity(uefEntity);System.out.println("executing request " + httppost.getURI());CloseableHttpResponse response = httpclient.execute(httppost);try {HttpEntity entity = response.getEntity();if (entity != null) {String entitys = EntityUtils.toString(entity, "UTF-8");System.out.println("--------------------------------------");System.out.println("Response content: " + entitys);System.out.println("--------------------------------------");Map<String, String> data = new LinkedHashMap<String, String>();JSONObject json = JSONObject.fromObject(entitys);Iterator<?> it = json.keys();// 遍历jsonObject数据,添加到Map对象while(it.hasNext()){String key = String.valueOf(it.next());String values = String.valueOf(json.get(key));if(key.equals("respMessage") || "MD5Info".equals(key)){continue;}data.put(key, values);}String respMessage = (String) json.get("respMessage");String matchMessage = (String) json.get("matchMessage");System.out.println("respMessage: " + respMessage);System.out.println("matchMessage: " + matchMessage);}} finally {response.close();}} catch (ClientProtocolException e) {e.printStackTrace();} catch (UnsupportedEncodingException e1) {e1.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {// 关闭连接,释放资源try {httpclient.close();} catch (IOException e) {e.printStackTrace();}}}}

上线前建议与客服沟通下,确认无误即可上线啦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。