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

时间:2020-06-18 13:33:40

标签: php laravel server centos centos7

我尝试了许多解决方案,但是没有人可以提供帮助。我正在为laravel项目使用google recaptcha,并且正在使用此库Cancel

这是我的代码视图

"buzz/laravel-google-captcha": "^2.2"

我在LoginController中的代码

<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>

我遇到错误

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

我尝试重新启动VPS,更新了我的密钥,并在配置public function validateLogin(Request $request){ $this->validate($request, [ $this->username() => 'required', 'password' => 'required', 'g-recaptcha-response' => 'required|captcha', ]); } allow_url_fopen=On中打开了

我仍然遇到错误。有人可以帮助我吗?在本地主机上工作正常

我正在使用centos 7,laravel 5.7

1 个答案:

答案 0 :(得分:1)

我认为您没有互联网。例如,尝试使用curl。使用SSH登录并测试:

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

或使用telnet

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

如果没有连接,则无法连接。然后,应检查该系统上是否安装了防火墙,或者系统前面是否有防火墙。