在全球范围内使用 reCAPTCHA [英] Using reCAPTCHA globally

查看:53
本文介绍了在全球范围内使用 reCAPTCHA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照 https://developers.google.com/recaptcha/docs/faq#can-i-use-recaptcha-globally.但是,它对我不起作用.

I am trying to use reCAPTCHA globally by following the instructions present at https://developers.google.com/recaptcha/docs/faq#can-i-use-recaptcha-globally . However, it is not working for me.

我替换了所有出现的https://www.google.com/recaptcha";与https://www.recaptcha.net/recaptcha"但我注意到它在内部仍然指的是 google.com.

I replaced all the occurrences of "https://www.google.com/recaptcha" with "https://www.recaptcha.net/recaptcha" but what I noticed is it is still referring to google.com internally.

https://www.recaptcha.net/recaptcha/api.js正在致电 https://www.gstatic.com/recaptcha/releases/TPiWapjoyMdQOtxLT9_b4n2W/recaptcha__en.js,它在内部指的是 google.com 主机.

https://www.recaptcha.net/recaptcha/api.js is making a call to https://www.gstatic.com/recaptcha/releases/TPiWapjoyMdQOtxLT9_b4n2W/recaptcha__en.js and it is internally referring to google.com host.

在我看来,ReCaptcha 代码已损坏.对此有何想法?

Looks like ReCaptcha code is broken to me. Any ideas on this?

推荐答案

使用 recaptcha.net 来解决这个问题不能解决问题,因为它会再次调用返回 google.com.

Using recaptcha.net for this problem is NOT going to solve the problem because it will again call back google.com.

所以这里我有一个解决方案.解决方案是使用 cURL.当您从 cURL 发出请求时,它实际上并不是来自客户端,而是充当用户和服务器之间的代理.

So here I have one solution. The solution is using cURL. When you do requests from cURL it does not actually go from the client but it works as a proxy between the user and the server.

在 PHP 语言中,你可以这样做:

In PHP language you can do it in this way:

reCaptcha.php

<?php
if (! function_exists ( 'curl_version' )) {
    exit ( "Enable cURL in PHP" );
}


$ch = curl_init ();
$timeout = 0; // 100; // set to zero for no timeout
$myHITurl = "https://www.google.com/recaptcha"; //domain which is blocked
curl_setopt ( $ch, CURLOPT_URL, $myHITurl );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "text=/");
$file_contents = curl_exec ( $ch );
if (curl_errno ( $ch )) {
    echo curl_error ( $ch );
    curl_close ( $ch );
    exit ();
}
curl_close ( $ch );

// dump output of api if you want during test
echo "$file_contents";
?>

因此,您可以向此 reCaptcha.php 文件发出请求,并使用此 reCaptcha.php 页面的输出作为响应.

So you can make a request to this reCaptcha.php file and use the output of this reCaptcha.php page as the response.

如果您不使用 PHP,则可以使用您自己项目的编程语言来完成此操作.您可能还需要根据您的需要进行一些修改,但您只需要使用 cURL,过程将保持不变.

If you are not using PHP you can do this with your own project's programming language. You may also need some modification according to your need but you just need to use cURL, the process will remain the same.

但这实现起来会非常复杂.因此,我建议您选择另一个验证码服务提供商,例如 hCaptcha,除非google 本身修复了从 recaptcha.net 发送到 google.com 的请求.

But this will be very complex to implement. So, I would advise you to go for another captcha service provider like hCaptcha unless google itself fixes the request sending to google.com from recaptcha.net.

这篇关于在全球范围内使用 reCAPTCHA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆