【问题标题】:Ne reCAPTCHA giving me a 403 errorNe reCAPTCHA 给我一个 403 错误
【发布时间】:2015-01-22 18:12:47
【问题描述】:

最近一位客户告诉我,他网站的 reCAPTCHA 不再有效。经过调查,我发现谷歌改变了它。我使用 2014 年 11 月 19 日的新文档升级了他们的网站,但它总是给我一个 403 错误。我尝试只提交密钥并返回一个带有错误和错误的 JSON 结果。我通过提交来自 g-recaptcha-response 字段的响应做了同样的事情,它还返回了带有错误的 JSON 结果。一旦我使用 http_build_query 将它们都放入一个字符串中,我就会从 Google 获得 403 禁止。

我正在使用新的http://www.google.com/recaptcha/api/siteverify 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);

任何帮助将不胜感激。

【问题讨论】:

  • 你的 JSON 结果到底是什么? (另外,我对 reCAPTCHA 了解不多,但从the documentation 的样子来看,您不应该使用 GET 请求,而不是 POST 参数吗?)

标签: php recaptcha


【解决方案1】:

你必须使用 https,所以正确的 URL 是:

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

这应该可以修复 403 错误。

【讨论】:

  • 我正在使用 https url:google.com/recaptcha/api/siteverify,但我收到错误 尝试了所有:1 个地址,但无法通过 HTTPS 连接到服务器:google.com 端口:443 .我在服务器端使用 Java 来验证 g-recaptcha-response 字符串。出现此错误的原因可能是什么?
  • 然后我得到could not open socket error haha​​hhaha
猜你喜欢
  • 2021-01-31
  • 2021-10-14
  • 2022-01-14
  • 2017-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多