Migrating from reCAPTCHA to GeeTest CAPTCHA
If you’re using reCAPTCHA and considering switching to GeeTest CAPTHCA v4, this part provides some suggestions of changing to GeeTest CAPTCHA step by step. As GeeTest CAPTCHA’s main logic flow is slightly different than reCAPTCHA or other CAPTCHA vendors, there are some extra steps you need to follow to finish the integration.
1. Get ID and KEY from Console
After creating the Application and Events, get the ID and Key.
ID works as reCAPTCHA’s site key. Key works as reCAPTCHA’s secret key.
2. Update client side
Replace the JavaScript file:
<script src="https://www.google.com/recaptcha/api.js" async defer></script> |
With following:
<script src="https://static.geetest.com/v4/gt4.js" async defer></script> |
For rendering the GeeTest CAPTCHA widget, replace DIV element g-recaptcha
with DIV element with your self-defined id name. The ID name captcha
is used here as example. The ID(reCAPTCHA’s site key) will be placed in the script.
<form action="?" method="POST"> |
Add the following code to the script with ID
<script> |
3. Update server side
Update reCAPTCHA’s siteverify API URL://php
api_url = 'https://www.google.com/recaptcha/api/siteverify'
and replaced it with GeeTest’s URL://php
api_url = 'https://gcaptcha4.geetest.com/validate'
In the API request body of reCAPTCHA, you have 2 parameters secret and response://php
data = {
'secret': secret, // The shared key between your site and reCAPTCHA
'response': response, // The user response token provided by the reCAPTCHA client-side integration on your site
}
Replace these 2 parameters with the following://php
data = {
"lot_number": lot_number, //serial number
"captcha_output": captcha_output, //Verification output data
"pass_token": pass_token, //Token of successful verification
"gen_time": gen_time, //timestamp
"captcha_id": captcha_id, //CAPTCHA ID
"sign_token": sign_token, //signature token
}
Update the reCAPTCHA’s verification result:
//php
{
"success": true|false, //Verification result
"challenge_ts": timestamp, // timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ)
"hostname": string, // the hostname of the site where the reCAPTCHA was solved
"error-codes": [...] // optional
}
and replace success
with result
to receive the verification result from GeeTest:
//php |