ID card Real-name authentication interface call code instance code description: php-based ID card Real-name authentication interface call code instance
// + ---------------------------------------------------------------------- // ---------------------------- // Real-name authentication for ID cards-aggregate data // online interface documentation: http://www.juhe.cn/docs/103//---------------------------------- Header ('content-type: text/html; charset = utf-8 '); // Configure Your applied appkey $ appkey = "*********************"; // ************* 1. check whether the real name and ID number are consistent ************ $ url =" http://op.juhe.cn/idcard/query "; $ Params = array (" idcard "=>" 3303291989 ********* ", // ID card number" realname "=>" Dong Hao Shuai ", // real name "key" => $ appkey, // application APPKEY (application details page query); $ paramstring = http_build_query ($ params ); $ content = juhecurl ($ url, $ paramstring); $ result = json_decode ($ content, true); if ($ result) {if ($ result ['error _ Code'] = '0') {if ($ result ['result'] ['res'] = '1 ') {echo "the ID card number is the same as the real name";} else {echo "the ID card number is different from the real name" ;## print_r ($ result);} else {Echo $ result ['error _ Code']. ":". $ result ['reason '] ;}} else {echo "request failed ";} //************************************** * ***********/***** request interface returned content * @ param string $ url [requested URL] * @ param string $ params [request parameter] * @ param int $ ipost [whether to use the POST form] * @ return string */function juhecurl ($ url, $ params = false, $ ispost = 0) {$ httpInfo = array (); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERS ION_1_1); curl_setopt ($ ch, CURLOPT_USERAGENT, 'juhedata'); curl_setopt ($ ch, hour, 60); curl_setopt ($ ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ ch, optional, true); curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true); if ($ ispost) {curl_setopt ($ ch, CURLOPT_POST, true); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ params); curl_setopt ($ ch, CURLOPT_URL, $ url) ;} Else {if ($ params) {curl_setopt ($ ch, CURLOPT_URL, $ url .'? '. $ Params);} else {curl_setopt ($ ch, CURLOPT_URL, $ url) ;}}$ response = curl_exec ($ ch); if ($ response === FALSE) {// echo "cURL Error :". curl_error ($ ch); return false;} $ httpCode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); $ httpInfo = array_merge ($ httpInfo, curl_getinfo ($ ch )); curl_close ($ ch); return $ response ;}