New reCAPTCHA with checkbox in infinite loop and don't send any value in g-recaptcha-response.

2,500 views
Skip to first unread message

Rémi Heppell

unread,
Nov 23, 2014, 3:36:25 PM11/23/14
to reca...@googlegroups.com
Hi everyone,

I'm trying to make the new reCAPTCHA work. Until now, the only solution i've found is by adding "?fallback=true" parameter to the following API call :

<script src="https://www.google.com/recaptcha/api.js?fallback=true" async defer></script>

Without "fallback", the reCAPTCHA is showing fine. After checking the box, the reCAPTCHA start in an infinite loop (recaptcha-checkbox-spinnerAnimation). This infinite loop is the correct behavior?

If I clic on "submit" button, i see the "g-recaptcha-response" in POST but there is no value. Because of that, you understand that there is no way to pass it to validation process.
I've tested on different computer with different
up to date browser (Chrome, Mozilla, IE) with javascript enabled.

Does anyone get it working? I'm trying to figuring out what is causing this.

Thanks for help!

Mary Kavitha

unread,
Nov 24, 2014, 1:28:36 AM11/24/14
to reca...@googlegroups.com
can you tell me how you post 'g-recaptcha-response'? I have also added the recaptcha to my form its showing fine. but i don't know how to verify user response.

Rémi Heppell

unread,
Nov 24, 2014, 1:44:29 AM11/24/14
to reca...@googlegroups.com
If you follow correctly the instruction at https://developers.google.com/recaptcha/, you have place your reCAPTCHA between your form tag. When you submit the form, the 'g-recaptcha-response' will be posted.

Mary Kavitha

unread,
Nov 24, 2014, 2:03:13 AM11/24/14
to reca...@googlegroups.com
where can i give this URI 'https://www.google.com/recaptcha/api/siteverify' and also my private key

Rémi Heppell

unread,
Nov 24, 2014, 2:09:50 AM11/24/14
to reca...@googlegroups.com
You decide where you form will be posted so you can specify the php file that handle POST values.

<form action="action_page.php">

You can request verification like this :
$userIP = $_SERVER["REMOTE_ADDR"];
$recaptchaResponse = $_POST["g-recaptcha-response"];
$secretKey = "yourkey";
$request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$recaptchaResponse."&remoteip=".$userIP);

Mary Kavitha

unread,
Nov 24, 2014, 8:00:46 AM11/24/14
to reca...@googlegroups.com
Thank you so much now its working. and can you help me with the json part. The '$request' returns { "success": true } when the captcha is correct and returns { "success": false, "error-codes": [ "missing-input-response" ] } when the captcha is incorrect. how can i check if the success is true? I really don't know JSON. 

Rémi Heppell

unread,
Nov 24, 2014, 11:37:33 PM11/24/14
to reca...@googlegroups.com
Base on what i've read and understand from help, you don't have to use JSON at all. The only case you could use it would be to enable the submit button only if the reCAPTCHA is valid. For that you'll need to put your siteverify code in another php file than the one receiving the post part. Then you'll have to overwrite the submit action to first check the validation via JSON call and then let the user continue with the form post.

To be back to my problem, after some check up, I found an error in console : cb=gapi.loaded_0:17 Uncaught Error: Illegal origin for connected iframe - undefined

This error don't appear with "?fallback=true".

Thanks for help.
Reply all
Reply to author
Forward
0 new messages