Verify Responses Server-Side
How it works
Code Examples
Javascript/Node.js
async function verifyCaptcha(token) {
const response = await fetch('http://api.gotcha.land/api/siteverify', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
secret: 'YOUR_SECRET_KEY', // ** Replace with your actual secret key **
response: token
})
});
const result = await response.json();
return result.success;
}
// Usage in an Express.js route
app.post('/submit-form', async (req, res) => {
const captchaToken = req.body['gotcha-response'];
const isValid = await verifyCaptcha(captchaToken);
if (isValid) {
// Process the form submission
res.json({ message: 'Form submitted successfully!' });
} else {
// Reject the submission
res.status(400).json({ error: 'Invalid CAPTCHA' });
}
});Rust
Last updated