0

我知道这个问题已经被问过了,但我的问题是错误 file_get_contents( https://www.google.com/recaptcha/api/siteverify ): failed to open stream: Connection timed out 间歇性和随机出现但大多数时候我从谷歌recaptcha API得到响应所以这个问题中提出的解决方案(file_get_contents(https://www.google.com/recaptcha/api/siteverify):未能打开流:连接超时) 不适用于我

我正在为我的网站使用共享主机。

另外我想告诉这个问题主要是在我连接 ssl 后出现的

这是我用于服务器端验证的 php 代码

$verify = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secretKey.'&response='.$_POST['g-recaptcha-response']);

我也试过这段代码

$verify = file_get_contents("https://www.google.com/recaptcha/api/siteverify",false,stream_context_create(array(
        'http' => array(
'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            'method' => 'POST',

            'content' => http_build_query(array(
                'secret'=> 'my_key',
                  'response'=> $_POST['g-recaptcha-response']
            ))
        )
    )));

但是这些都不能解决问题,请帮助我

4

0 回答 0