Laravel 中的验证 recaptchaV3

validation recaptchaV3 in Laravel

我正在尝试将 recaptchaV3 添加到一个网络中,但总是在 json_decode() 中返回错误我用 echo 检查了我的 .env 变量值,没关系,但是响应从验证是错误的。在开发的 google 控制台中,我配置了我的 ky。我正在使用这段代码:

$url = "https://www.google.com/recaptcha/api/siteverify";
        $data = [
            'secret'   => env("RECAPTCHAV3_SECRET"),
            'response' => request('recaptcha')
        ];

        $options = [
            'http'  => [
                'header'    => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'    => 'POST',
                'content'   => http_build_query($data)
            ]
        ];
        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
        $resultJson = json_decode($result);

        if($resultJson->success != true){
            echo "Captcha Error"; 
            exit();

        }else{

            $data = $request->all();

            // SEND EMAIL
            \Mail::send('web.emailContact', $data, function($message) use ($request)
            {
                $message->from($request->email, $request->name);
                $message->subject("Prueba formulario contacto");
                $message->to("daviserraalonso@gmail.com");
            });
        }

我不得不说验证码 V3 图像显示在网络的右上角...为此我认为我很好地集成了验证码,但是当我发送我的表单时,返回 Catcha Error

首先我有这个代码:

$validate = \Validator::make(Input::all(), [
            'g-recaptcha-response' => 'required|recaptchav3:register,0.5',
            'name'  => 'required|min:3',
            'email' => 'required|email',
            'phone' => 'required|min:9'
        ]);

        //check if validation it´s correct
        if($validate->fails()){
            \Redirect::back()->withErrors($validate->messages())->withInput();
        }else{
            return \Redirect::route('contact')->withMessage("Mensaje enviado correctamente");
        }


        $score = \RecaptchaV3::verify($request->get('g-recaptcha-response'));
        if($score > 0.7) {
            // go
        } elseif($score > 0.3) {
            // require additional email verification
        } else {
            return abort(400, 'You are most likely a bot');
        }

但是这段代码,总是返回 else 块。

我希望任何人都可以帮助我。

奖励

我解决了我的问题:

我的验证码名字错了

$url = "https://www.google.com/recaptcha/api/siteverify";
        $data = [
            'secret'   => env("RECAPTCHAV3_SECRET"),
            'response' => request('reCaptcha')
        ];

        $options = [
            'http'  => [
                'header'    => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'    => 'POST',
                'content'   => http_build_query($data)
            ]
        ];
        
        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
        $resultJson = json_decode($result);

        if($resultJson->success != true){
            echo "Captcha Error"; 
            exit();