PHP-GoogleReCAPTCHA代理设置
我正在使用Google Recaptcha的PHP包装库。PHP-GoogleReCAPTCHA代理设置,php,symfony,security,proxy,recaptcha,Php,Symfony,Security,Proxy,Recaptcha,我正在使用Google Recaptcha的PHP包装库。 我需要设置一个代理,但据我调查,这个库不支持代理配置 是否有人有机会成功为Google Recaptcha配置代理配置 这是在没有代理的服务器上正常工作的代码 /** * RecaptchaService constructor. * * @param ReCaptcha $recaptcha */ public function __construct(ReCaptcha $r
我需要设置一个代理,但据我调查,这个库不支持代理配置 是否有人有机会成功为Google Recaptcha配置代理配置 这是在没有代理的服务器上正常工作的代码
/**
* RecaptchaService constructor.
*
* @param ReCaptcha $recaptcha
*/
public function __construct(ReCaptcha $recaptcha)
{
$this->recaptcha = $recaptcha;
}
/**
* @param array $data
*
* @return bool
*/
public function validateCaptcha(array $data): bool
{
$response = $this->recaptcha->verify($data['gRecaptchaResponse'], $data['clientIp']);
return $response->isSuccess() || \PHP_SAPI === 'cli';
}
我想应该在
verify
方法调用之前或之内配置代理。有一个支持代理的Google ReCaptcha库
$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();
}