sys_config('real_access_id'), "accessKeySecret" => sys_config('real_access_secret'), "endpoint" => $endpoint ]); return new Cloudauth($config); } /** * @return ContrastFaceVerifyResponse|null */ public static function check($order_id, $real_name, $card_number, $image) { $request = new ContrastFaceVerifyRequest([ // 请输入场景ID。 "sceneId" => sys_config('real_scene_id'), "outerOrderNo" => $order_id, // 要接入的认证方案。 "productCode" => "ID_MIN", // 要进行活体检测的类型。 "model" => "NO_LIVENESS", "certType" => "IDENTITY_CARD", "certName" => $real_name, "certNo" => $card_number, "faceContrastPicture" => $image, ]); // 推荐,支持服务路由。 $response = self::contrastFaceVerifyAutoRoute($request); return $response; } /** * @param ContrastFaceVerifyRequest $request * @return ContrastFaceVerifyResponse */ public static function contrastFaceVerifyAutoRoute(ContrastFaceVerifyRequest $request) { $endpoints = [ "cloudauth.cn-shanghai.aliyuncs.com", "cloudauth.cn-beijing.aliyuncs.com" ]; foreach ($endpoints as $endpoint) { try { $response = self::contrastFaceVerify($endpoint, $request); if (Utils::equalString("500", $response->code)) { continue; } return $response; } catch (Exception $err) { if (!($err instanceof TeaError)) { $err = new TeaError([], $err->getMessage(), $err->getCode(), $err); } // 网络异常,切换到下个区域调用。 if (Utils::equalString("ServiceUnavailable", $err->code)) { continue; } } } return null; } /** * @param string $endpoint * @param ContrastFaceVerifyRequest $request * @return ContrastFaceVerifyResponse */ public static function contrastFaceVerify($endpoint, $request) { $client = self::createClient($endpoint); // 创建RuntimeObject实例并设置运行参数。 $runtime = new RuntimeOptions([]); $runtime->readTimeout = 10000; $runtime->connectTimeout = 10000; return $client->contrastFaceVerify($request, $runtime); } }