dongzhiyan5693 2017-03-07 06:36
浏览 56
已采纳

从aadhaar号码获取用户信息

How to get the user information from user mobile number and aadhaar number in php ?

Input as user mobile number and aadhaar number Output as user details like user name(first name and last name),mobile number and profile image.

General we did user social login we give email-id and fetch the details and here we need to give aadhaar number and fetch the details

Is any api or how to get the user details from aadhaar number and mobile number ?

I use below code but not working for me

<?php
$adhar_card_no = "";

function buildUrl($adhar_card_no)
{
    $host = "http://auth.uidai.gov.in";
    $version = 1.6;
    $aua = "";
    $asalk = "";
    $uid = str_split($adhar_card_no);
    $url =  $host."/".$version."/".$aua."/".$uid[0]."/".$uid[1]."/".$asalk;
    return $url;
}

function requestDataBuilder($uid)
{
    $encrypted_encoded_session_key = "";
    $encrypted_pid_block = "";
    $sha256_pid_bloc_encrypted_encoded= "";
    $digital_aua_signatrure= "";
    /**
     * Authentication data to send request --Mandatory
     */
    $auth_data = [
        "uid" => $uid, //Adhaar Card No.
        "tid" => "", //Terminal Id for registered device else public
        "ac" => "", //10 char unique code, public for testing
        "sa" => "", //max length 10, same as ac possible
        "ver" => 1.6, //Current version
        "txn" => "", //AUA transaction  identifier. max length 50, not U*
        "lk" => "", //Valid License Key, max length 64
    ];
    /**
     * Uses data comprises of options as yes (y) or no (n) -- Mandatory
     */
    $uses_data = [
        "pi" => "n",
        "pa" => "n",
        "pfa" => "n",
        "bio" => "n",
        "bt" => "n",
        "pin" => "n",
        "otp" => "n"
    ];
    /**
     * Token data -- optional
     */
    $tkn_data = [
        "type" => "001", //only this option available for now which is mobile no.
        "value" => "" //Mobile no. 10 digit only no prefix
    ];
    /**
     * Meta Data Mandatory
     */
    $meta_data = [
        "udc" => $udc, //[vendorcode][date of deployment][serial number] max length 20
        "fdc" => "NA", //Fingerprint device code. use NA or NC or given code
        "idc" => "NA", //Iris device  code,  us na or NC
        "pip" => "NA", //Public IP address of the device, or NA
        "lot" => "P", //G -lat long format. p for pincode format
        "lov" => "110025" // value as per G and P- my pin change it
    ];
    /**
     * Skey data -- Mandatory
     */
    $skey_data = [
        "ci" => "", //Public key certificate Identifier --mandatory
        "ki" => "" //This is for advanced use only, --optional
    ];

    $format = '<Auth uid="'.$auth_data['uid'].'" tid ="'.$auth_data['tid'].'" ac="'.$auth_data['ac'].'" sa="'.$auth_data['sa'].'" ver="'.$auth_data['ver'].'" txn="'.$auth_data['txn'].'" lk="'.$auth_data['lk'].'">';
    $format.= '<Uses pi="'.$uses_data['pi'].'" pa="'.$uses_data['pa'].'" pfa="'.$uses_data['pfa'].'" bio="'.$uses_data['bio'].'" bt="'.$uses_data['bt'].'" pin="'.$uses_data['pin'].'" otp="'.$uses_data['otp'].'"/>';
    $format.= '<Tkn type="'.$tkn_data['type'].'" value="'.$tkn_data['value'].'"/>';
    $format.= '<Meta udc="'.$meta_data['udc'].'" fdc="'.$meta_data['fdc'].'" idc="'.$meta_data['idc'].'" pip="'.$meta_data['pip'].'" lot="'.$meta_data['lot'].'" lov="'.$meta_data['lov'].'"/>';
    $format.= '<Skey ci="'.$skey_data['ci'].'" ki="'.$skey_data['ci'].'">'.$encrypted_encoded_session_key.'</Skey>';
    $format.= '<Data type="X">'.$encrypted_pid_block.'</Data>';
    $format.= '<Hmac>'.$sha256_pid_bloc_encrypted_encoded.'</Hmac>';
    $format.= '<Signature>'.$digital_aua_signatrure.'</Signature></Auth>';
    return $format;    

}
$request_url = buildUrl($adhar_card_no); echo "<br>";
$data_to_send = requestDataBuilder($adhar_card_no); 

//setting the curl parameters.
$ch = curl_init();
$curl_options = [
    CURLOPT_URL => $request_url,
    CURLOPT_VERBOSE => 1,
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_SSL_VERIFYPEER => 0,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_HTTPHEADER => array('Content-Type: application/xnl'),
    CURLOPT_POSTFIELDS => $data_to_send
];
curl_setopt_array($ch, $curl_options);
if (curl_errno($ch)) {
// moving to display page to display curl errors
    echo curl_errno($ch) ;
    echo curl_error($ch);
} else {
    //getting response from server
    $response = curl_exec($ch);
    print_r($response);
    curl_close($ch);
}
?>

Please kindly post your code

  • 写回答

1条回答 默认 最新

  • duanhuan2301 2017-04-04 12:01
    关注

    You cannot get the aadhaar details like as you are calling. You have to call their web services which required digitally signed request. First of all you should have digital certificate for signing request and you have to sign an agreement with aadhaar to use their services.

    You can check this link as reference for your queries : https://groups.google.com/forum/#!forum/aadhaarauth

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器