PHP code example of toskadv / recaptcha
1. Go to this page and download the library: Download toskadv/recaptcha library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
toskadv / recaptcha example snippets
$curl = new ReCaptcha\RequestMethod\CurlPost(null, null, [
CURLOPT_PROXY => 'http://127.0.0.1:9050/',
CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5
]);
$recaptcha = new \ReCaptcha\ReCaptcha($secret, $curl);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
// verified!
} else {
$errors = $resp->getErrorCodes();
}
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
// Verified!
} else {
$errors = $resp->getErrorCodes();
}
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
->setExpectedAction('homepage')
->setScoreThreshold(0.5)
->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
// Verified!
} else {
$errors = $resp->getErrorCodes();
}