http(s)://api.hanvon.com/rt/ws/v1/ocr/passport/recg?key=yourKey&code=48aa4d87-5e12-42a9-82cd-4abb75577039
key:请到开发中心-->应用管理-->Key管理,在您的Key列表中找到对应的Key
code:code为固定值,直接使用url中的code即可
字段 | 描述 |
---|---|
uid | 您的服务器IP地址。 |
image | 图像的base64串 |
<?php //定义请求的url地址 $url = "http://api.hanvon.com/rt/ws/v1/ocr/passport/recg?key=your_android_key&code=48aa4d87-5e12-42a9-82cd-4abb75577039"; //模拟发送POST请求(CURL四步走) //第一步:初始化curl $ch = curl_init(); //第二步:设置相关参数 //设置请求的url地址 curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止SSL证书的校检功能 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //模拟发送POST请求 curl_setopt($ch, CURLOPT_POST, 1); $image=base64_encode(file_get_contents('1.jpg')); var_dump($image); $arr = array ('uid'=>'0.0.0.0','image'=>$image); $data = json_encode($arr); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //第三步:执行curl $output = curl_exec($ch); //判断输出结果是否异常 if($output===false) { echo curl_error($ch); } else { var_dump($output); } //第四步:关闭curl curl_close($ch); ?>
字段 | 父字段 | 描述 |
---|---|---|
code | response | 返回码 |
result | response | 消息内容 |
type | response | 类型 |
countryCode | response | 国家码 |
passportNo | response | 护照号 |
surname | response | 姓 |
givenNames | response | 名 |
sex | response | 性别 |
dateOfBirth | response | 出生日期 |
dateOfIssue | response | 签发日期 |
authority | response | 签发机关 |
placeOfBirth | response | 出生地点 |
placeOfIssue | response | 签发地点 |
dateOfExpiry | response | 有效期至 |
mrpCode1 | response | 机读码1 |
mrpCode2 | response | 机读码2 |
Success:
Failure:
1. 护照尽可能充满整个画面。
2. 拍摄时,请保持光线充足,不要有阴影和反光。
3. 请对焦后进行拍摄,尽量避免抖动。
4. 为提高识别率,文本分辨率最少300dpi以上。
5. 为提高识别率,护照下方两行机读码一定要包含在图片中。