二代身份证智能识别服务。提升效率,节约成本,降低风险,提升用户体验
无参数
无参数
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
secret_key | string | true | 用户授权key |
secret_code | string | true | 接口编号 |
secret_sign | string | true | 加密签名:md5(secret_key+secret_secret)转大写 |
image | string | true | 图像数据,base64编码。图片最短边至少15px,最长边最大4096px |
side | string | true | front:身份证含照片的一面;back:身份证带国徽的一面 |
detectDirection | boolean | true | 检测图像旋转角度,默认检测,即:true。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。- true:检测旋转角度; - false:不检测旋转角度。 |
detectRisk | boolean | true | 是否开启身份证风险类型(身份证复印件、临时身份证、身份证翻拍、修改过的身份证)功能,默认不开启,即:false。可选值:true-开启;false-不开启 |
curl http://cloud.kuaidi100.com/api -X POST -d \
"secret_key=***&secret_code=399d4fec7299432b96928ad2657e3996&secret_sign=md5(***)&image=&side=front&detectDirection=true&detectRisk=false"
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
public class CloudDemo {
public static void main (String[] args) {
CloudDemo cloudDemo = new CloudDemo();
Map params = new HashMap();
params.put("secret_key", "***");
params.put("secret_code", "399d4fec7299432b96928ad2657e3996");
params.put("secret_sign", "md5(***)");
params.put("image", "");
params.put("side", "front");
params.put("detectDirection", "true");
params.put("detectRisk", "false");
cloudDemo.post(params);
}
public String post(Map params) {
StringBuilder response = new StringBuilder("");
BufferedReader reader = null;
try {
StringBuilder builder = new StringBuilder();
for (Map.Entry param : params.entrySet()) {
if (builder.length() > 0) {
builder.append('&');
}
builder.append(URLEncoder.encode(param.getKey(), "UTF-8"));
builder.append('=');
builder.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] bytes = builder.toString().getBytes("UTF-8");
URL url = new URL("http://cloud.kuaidi100.com/api");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
conn.setRequestMethod("POST");
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(bytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(bytes);
reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line = "";
while ((line = reader.readLine()) != null) {
response.append(line);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != reader) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return response.toString();
}
}
class MD5Utils { private static MessageDigest mdigest = null;
private static char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
private static MessageDigest getMdInst() {
if (null == mdigest) {
try {
mdigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
return mdigest;
}
public static String encode(String s) {
if(null == s) {
return "";
}
try { byte[] bytes = s.getBytes();
getMdInst().update(bytes);
byte[] md = getMdInst().digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for(int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = digits[byte0 >>> 4 & 0xf];
str[k++] = digits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
暂无示例
<?php
$params = "";
$params .= 'secret_key=***'.'&';
$params .= 'secret_code=399d4fec7299432b96928ad2657e3996'.'&';
$params .= 'secret_sign=md5(***)'.'&';
$params .= 'image='.'&';
$params .= 'side=front'.'&';
$params .= 'detectDirection=true'.'&';
$params .= 'detectRisk=false'.'&';
$params .= substr($params, 0, -1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, 'http://cloud.kuaidi100.com/api');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo $result;
?>
# coding = utf-8
import sys,os
import requests,json,hashlib
params = {}
params['secret_key'] = '***'
params['secret_code'] = '399d4fec7299432b96928ad2657e3996'
params['secret_sign'] = 'md5(***)'
params['image'] = ''
params['side'] = 'front'
params['detectDirection'] = 'true'
params['detectRisk'] = 'false'
result = requests.post('http://cloud.kuaidi100.com/api', params)
print(result.text)
无参数
{
"code": 200,
"message": "success",
"data": {
"taskId": "7884706509000406618", //唯一的taskid,用于问题定位
"address": { //住址
"text": "安徽省宿州市埇桥区朱仙庄镇", //识别结果字符串
"location": { //位置数组(坐标0点为左上角)
"x": 659, //表示定位位置的长方形左上顶点的水平坐标
"y": 1093, //表示定位位置的长方形左上顶点的垂直坐标
"width": 1047, //表示定位位置的长方形的宽度
"height": 220 //表示定位位置的长方形的高度
}
},
"id": { //身份证号码
"text": "652901196611026716",
"location": {
"x": 1060,
"y": 1620,
"width": 1399,
"height": 101
}
},
"birth": { //出身日期
"text": "19661102",
"location": {
"x": 663,
"y": 873,
"width": 832,
"height": 94
}
},
"name": { //姓名
"text": "徐乐",
"location": {
"x": 663,
"y": 449,
"width": 279,
"height": 111
}
},
"sex": { //性别
"text": "男",
"location": {
"x": 666,
"y": 679,
"width": 70,
"height": 88
}
},
"nation": { //民族
"text": "汉",
"location": {
"x": 1183,
"y": 683,
"width": 70,
"height": 78
}
},
"direction": 0, //图像方向,当 detect_direction = true 时,返回该参数。
"riskType": "normal" //输入参数 detect_risk = true 时,则返回该字段识别身份证类型: normal-正常身份证;copy-复印件;temporary-临时身份证;screen-翻拍;unknown-其他未知情况
}
}
{
"code": 20003,
"message": "未检测到图片中识别目标",
"data": null
}
状态码 | 状态码信息 | 描述 |
---|---|---|
200 | success | 成功 |