Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Ne reCAPTCHA给我一个403错误_Php_Recaptcha - Fatal编程技术网

Php Ne reCAPTCHA给我一个403错误

Php Ne reCAPTCHA给我一个403错误,php,recaptcha,Php,Recaptcha,最近,一位客户告诉我,他的网站的reCAPTCHA已经失效。经过调查,我发现谷歌改变了它。我从2014年11月19日起使用新文档升级了他们的网站,但它总是给我一个403错误。我尝试只提交密钥,结果返回一个JSON结果,结果为false和一个错误。我也这样做了,只是从g-recaptcha-response字段提交了响应,它还返回了一个带有错误的JSON结果。当我使用http\u build\u查询将它们都放入一个字符串中时,我从谷歌得到了一个403禁止 我正在使用新的URL。我使用以下代码使用P

最近,一位客户告诉我,他的网站的reCAPTCHA已经失效。经过调查,我发现谷歌改变了它。我从2014年11月19日起使用新文档升级了他们的网站,但它总是给我一个403错误。我尝试只提交密钥,结果返回一个JSON结果,结果为false和一个错误。我也这样做了,只是从g-recaptcha-response字段提交了响应,它还返回了一个带有错误的JSON结果。当我使用http\u build\u查询将它们都放入一个字符串中时,我从谷歌得到了一个403禁止

我正在使用新的URL。我使用以下代码使用PHP cURL提交:

    $post_data = array('response'=>$response, 'secret'=>$privatekey);
    $curlPost = http_build_query($post_data, '', '&');

    $ch = curl_init();

    //Set the URL of the page or file to download.
    $url = 'http://www.google.com/recaptcha/api/siteverify';

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);

    $data_json = curl_exec($ch);

非常感谢您的帮助。

您必须使用https,因此正确的URL为:

$url = 'https://www.google.com/recaptcha/api/siteverify';

这将修复403错误。

您的JSON结果是什么?(另外,我对reCAPTCHA了解不多,但从外观上看,您不应该使用GET请求,而不是发布参数吗?)我使用https url:但我得到错误尝试了所有:1个地址,但无法通过https连接到服务器:google.com端口:443。我在服务器端使用Java验证g-recaptcha-response字符串。这个错误的原因可能是什么?但是我得到了
无法打开套接字错误
哈哈哈