zoukankan      html  css  js  c++  java
  • PHP语言对用户输入的身份证信息进行实名认证(api接口)

    系统开发的时候经常会需要对用户做什么认证,用户提交的身份证信息如何对其进行真实性判定呢?我们已通过阿里云提供的身份证实名认证接口对信息进行验证,通过接口将用户提交的信息转送至身份证核验中心进行核验。

    先购买接口服务:https://market.aliyun.com/products/57000002/cmapi025518.html#sku=yuncode1951800000

    下面是对其认证的实例程序:

    <?php
    $host = "https://idenauthen.market.alicloudapi.com";
    $path = "/idenAuthentication";
    $method = "POST";
    $appcode = "你自己的AppCode"; //服务购买成功之后点击跳转至阿里云控制台,可看到AppCode
    $headers = array();
    array_push($headers, "Authorization:APPCODE " . $appcode);
    //根据API的要求,定义相对应的Content-Type
    array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
    $querys = "";
    $bodys = "idNo=340421190210182345&name=%E5%BC%A0%E4%B8%89";
    $url = $host . $path;

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_FAILONERROR, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HEADER, true);
    if (1 == strpos("$".$host, "https://"))
    {
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    }
    curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
    var_dump(curl_exec($curl));

    curl_close( $curl );
    $result_json = json_decode($response,true);
    ?>
    返回示例:

    {
    "name": "张三",
    "idNo": "340421190710145412",
    "respMessage": "身份证信息匹配",
    "respCode": "0000",
    "province": "安徽省",
    "city": "淮南市",
    "county": "凤台县",
    "birthday": "19071014",
    "sex": "M",
    "age": "111"
    }
    其他详细信息在页面中间都有说明,其他不明白的地方可以联系交流!

    搬砖快乐!

  • 相关阅读:
    VlanTrunk
    2015届互联网名企校招网址一览表
    The declared package does not match the expected package
    经典的算法网站
    Nutch
    JTable只要一双击就进入编辑状态,禁止的方法实现
    Java通过JDBC链接数据库,数据库中wen
    Cisco Packet Tracer的使用(一)
    Nutch安装的几个网址
    面试经
  • 原文地址:https://www.cnblogs.com/ruidongjun/p/14944989.html
Copyright © 2011-2022 走看看