Narendra
Narendra

Reputation: 5773

Using 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.

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 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.

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

Upvotes: 3

Views: 3460

Answers (2)

Manish
Manish

Reputation: 962

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

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.

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";
?>

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

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.

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.

Upvotes: 1

Leonardo Goes
Leonardo Goes

Reputation: 199

As stated by some comments, google's system choose the best URL, you can't force it to get from recaptcha.net. Trying to override your link may break it at anytime as stated in this post from recaptcha's support group

Upvotes: 1

Related Questions