laravel 5.2 greggilbert / recaptcha:请确保你是一个人

问题描述 投票:3回答:2

我在laravel 5.2项目中使用了greggilbert / recaptcha。虽然表格数据有效,但在提交表格后我总是收到错误信息:请确保你是一个人!

我尝试了很多,但没有找到任何解决方案。你有人帮我吗?请。

我用这些代码:

在表格中:

 <div class="form-group">
            <div class="input-group">
                {!! Recaptcha::render() !!}
            </div>
        </div>

要获取错误消息,

@section('message')
@if (count($errors) > 0)
    <h3>Message Sending Failed!</h3>
    <ul>
        @foreach ($errors->all() as $error)
            <li>{{ $error }}</li>
        @endforeach
    </ul>
@else
    <h3>
        @if(isset($heading))
            {{$heading}}
        @endif
    </h3>
    <p>
        @if(isset($body))
            {{$body}}
        @endif
    </p>
@endif

@endsection

在控制器中:

public function save(Request $request){

    $this->validate($request, [
        'Name' => 'required|max:40',
        'Email' => 'email|required',
        'Heading' => 'required|max:200',
        'Message' => 'required|max:1000',
        'g-recaptcha-response' => 'required|recaptcha',
    ]);

    $contact = new Contact();

    $contact->name = $request->Name;
    $contact->email = $request->Email;
    $contact->heading = $request->Heading;
    $contact->message = $request->Message;

    $contact->save();

    $msg['heading'] = 'Thank You! for contacting us.';
    $msg['body'] = 'We will try to Answer to your Query as soon as possible.';

    return redirect('/contact')->with($msg);

}

在config / recaptcha.php中

'public_key'     => env('RECAPTCHA_PUBLIC_KEY', '6LfjMiETAA_Rest of the key Hidden'),
'private_key'    => env('RECAPTCHA_PRIVATE_KEY', '6LfjMi_Rest of the key Hidden'),
laravel recaptcha
2个回答
3
投票

问题解决了:

将'curl_timeout'=> 1更改为'curl_timeout'=> 10后,在config / recaptcha.php


0
投票

请更改config / recaptcha.php

在recaptcha.php文件中设置以下选项

'options'     => [

    'curl_timeout' => 10,
    'curl_verify' => false,

],
© www.soinside.com 2019 - 2024. All rights reserved.