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

时间:2016-05-31 21:20:58

标签: laravel recaptcha

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

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

我使用了这些代码:

在表格中:

 <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'),

2 个答案:

答案 0 :(得分:3)

解决问题:

改变之后     &#39; curl_timeout&#39; =&GT; 1, 至 &#39; curl_timeout&#39; =&GT; 10, 在config / recaptcha.php

答案 1 :(得分:0)

请更改config / recaptcha.php

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

'options'     => [

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

],