$accountNo, 'name' => $name, 'idCardCode' => $idCard, 'bankPreMobile' => $bankPreMobile ]); $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15 ]); $response = curl_exec($ch); curl_close($ch); Log::info("阿里云四要素: {$idCard}, {$name}, {$accountNo}, {$bankPreMobile}, 结果: {$response}"); $ret = json_decode($response, true); if (!isset($ret['error_code']) || !isset($ret['result'])) { throw new SysException("阿里云接口返回格式错误".$response); } $errorCode = $ret['error_code']; $result = $ret['result']; $respCode = $result['respCode'] ?? ''; if ($errorCode == 0 && $respCode === "0") { // 验证通过 } else { throw new SysException($result['respMsg'] ?? '认证失败'); } $bankName = $result['bancardInfor']['bankName'] ?? null; return [ 'bankName' => $bankName, 'respJson' => $response ]; } private static function isValidIdCard($idCard) { // 简单校验身份证号 return preg_match('/^\d{17}[\dXx]$/', $idCard); } }