java - 二代身份证信息提取方案的选择?
PHP中文网
PHP中文网 2017-04-17 17:41:59
0
2
537

现在的系统需要通过身份证得到身份信息(姓名、性别、生日、籍贯、开卡地、头像、身份证照片...)。搜了半天也没契合的问答条目,只好开问求解。
以前没涉及过硬件开发的项目,现在查资料发现通常有两个方案:
第一,首先通过二代身份证读卡器读取身份证号,然后通过身份证号去调用公安部的服务(WebService技术)返回身份信息。
第二,通过专门的软硬件和模版的方式抓取身份证上的信息(只包含身份证上可见的信息)。

普通网吧、酒店应该都是第一种吧。系统平台为javaee开发,想问一下到底那种可行性高,如果采用第一种需要掌握那些开发技术和细节?(可能有说的不到位地方,大神给补充一下。)

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
洪涛

Unfortunately, ordinary Internet cafes and the like used the second type before. I haven’t done this in several years, so I don’t know if the first option you mentioned is feasible now. In the past, only a few companies could make this kind of hardware to identify ID cards. When we were doing real estate registration, we were out of stock. You can check the companies that can do it. The second option is much more convenient.

阿神

I deleted this answer before because I didn’t understand the question clearly. This answer did not solve the question. However, at the request of the questioner, the editor here can use markdown to highlight the code. Let’s do it again. Write an answer. Master, please ignore ^_^
Use services on Baidu api to extract identity information

Copy the code and save it as html in Notepad !
(Please do not run the following code on lower versions of IE)

<html>
<head>
<script type="text/javascript" src="http://cdn.gbtags.com/jquery/1.11.1/jquery.min.js"></script>  
<style>
body{  
    background:#CFCFCF;  
}  
 form {  
            border: 1px solid #467;  
            border-radius: 5px;  
            font: 14px/1.4 "Helvetica Neue", Helvetica, Arial, sans-serif;  
            overflow: hidden;  
            padding: 10px;  
            width: 300px;  
            color: #456;  
            margin: 15px;  
        }  
  
        p {  
            margin: 15px;  
            color: #346;  
        }  
  
        button {  
            display: inline-block;  
            padding: 6px 12px;  
            margin-bottom: 0;  
            line-height: 1.4;  
            text-align: center;  
            cursor: pointer;  
            border-radius: 4px;  
            border: 1px solid transparent;  
            color: #fff;  
            background: #1aba9c;  
        }  
  
        input {  
            display: inline-block;  
            padding: 6px 12px;  
            font-size: 14px;  
            line-height: 1.42857143;  
            color: #555;  
            background-color: #fff;  
            border: 1px solid #ccc;  
            border-radius: 4px;  
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);  
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);  
            -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;  
            -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;  
            transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;  
        }  
</style>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {  
        //headers中提供了apikey供服务器识别并返回数据。如果请求返回的data中提示试用次数用尽,请更换此处的apikey为你自己账号的apikey后再试  
        var headers = {"apikey": "5292d6abaf0ec95c2b7924551e50668f"};  
  
        $("#idBtn").click(function () {  
            {  
                $("#result").attr("style","display:none");  
                var id = $("#idIn").val();  
                if (id == "") {  
                    $(".res").remove();  
                    $("#container").append("<p class='res'>" + "请输入要查询的身份证号再点击按钮!");  
                }  
                else {  
                    //url变量指定了http访问的地址  
                    var url = "http://apis.baidu.com/apistore/idservice/id";  
                    url = url + "?id=" + id;  
                    console.dir(url);  
                    $.ajax(url, {  
                        method: "GET",  
                        headers: headers,  
                        dataType: "json",  
                        success: function (data) {  
                            console.dir(data);  
                           if (data.errNum == "-1") {  
                                $(".res").remove();  
                                $("#container").append("<p class='res'>" + "身份证号码不合法!");  
                            }  
                            else {  
                                $(".res").remove();  
                                if (data.retData.sex == 'M')  
                                    $("#gend").text("男");  
                                else if (data.retData.sex == 'F') {  
                                    $("#gend").text("女");  
                                }  
                                else {  
                                    $("#gend").text("未知");  
                                }  
                                $("#birth").text(data.retData.birthday);  
                                $("#addr").text(data.retData.address);  
                               $("#result").attr("style","display:block");  
                            }  
                        }  
                    });  
                }  
  
            }  
        });  
    });  
</script>
</head>
<body>
<p id="container">  
    <table>  
        <tr>  
            <td>  
                <input id="idIn" type="text">  
            </td>  
            <td>  
                <input id="idBtn" type="button" value="查询">  
            </td>  
        </tr>  
    </table>  
</p>  
<table id="result" style="display: none">  
    <tr>  
        <td>性别</td>  
        <td id="gend"></td>  
    </tr>  
    <tr>  
        <td>出生日期</td>  
        <td id="birth"></td>  
    </tr>  
    <tr>  
        <td>归属地</td>  
        <td id="addr"></td>  
    </tr>  
</table>  
</body>
</html>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!