![](/img/trans.png)
[英]Can't read XML file. (file_get_contents failed to open stream: Connection timed out)
[英]file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: Connection timed out
我嘗試了許多解決方案,但沒有人能提供幫助。 我正在為我的 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 ):未能打開 stream:連接超時
我已經嘗試重新啟動我的 VPS,我已經更新了我的密鑰,我已經打開了配置allow_url_fopen=On
和allow_url_include=On
我仍然得到錯誤。 任何人都可以幫助我嗎? 它在本地主機中工作正常
我正在使用 centos 7、laravel 5.7
我認為你沒有互聯網訪問權限。 以 curl 為例進行嘗試。 使用 SSH 登錄並測試:
curl https://www.google.com/recaptcha/api/siteverify
或使用遠程登錄
telnet https://www.google.com/recaptcha/api/siteverify 443
如果沒有連接,則無法連接。 然后你應該檢查你的系統上是否安裝了防火牆,或者你的系統前面是否有防火牆。
我在使用buzz/laravel-google-recaptcha
所基於的google/recaptcha
時遇到了類似的問題。 更改請求方法已修復它。
$recaptcha = new \ReCaptcha\ReCaptcha('secret', new \ReCaptcha\RequestMethod\CurlPost);
我猜你也可以在buzz/laravel-google-recaptcha
配置中更改它。 在這里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.