提问者:小点点

file_get_contents(https://www.google.com/recaptcha/api/siteVerify):无法打开流:连接超时


我试过很多办法,但没人能帮上忙。 我正在为我的laravel项目使用google recaptcha,我正在使用这个库“buzz/Laravel-google-captcha”:“^2.2”

这就是我的代码

<div class="col-md-6">
   @php($attributes = [])
      {!! Form::captcha($attributes) !!}
      @if ($errors->has('g-recaptcha-response'))
         <span class="invalid-feedback" style="display: block;">
                <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
         </span>
      @endif
</div>

我在LoginController中的代码

public function validateLogin(Request $request){
        $this->validate($request, [
            $this->username() => 'required',
            'password' => 'required',
            'g-recaptcha-response' => 'required|captcha',

        ]);
}

我出错了

file_get_contents(https://www.google.com/recaptcha/api/siteVerify):无法打开流:连接超时

我已尝试重新启动我的VPS,我已更新我的密钥,我已在配置中打开allow_url_fopen=onallow_url_include=on

我还是发现了错误。 有人能帮我吗? 在localhost中运行良好

我用的是centos 7,laravel 5.7


共1个答案

匿名用户

我想你没有上网。 比如用卷曲试试。 使用SSH登录并测试:

curl https://www.google.com/recaptcha/api/siteverify

或使用telnet

telnet https://www.google.com/recaptcha/api/siteverify 443

如果没有连接,你就无法连接。 那么您应该检查是否在该系统上安装了防火墙,或者是否在您的系统前面安装了防火墙。