Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-GoogleReCAPTCHA代理设置_Php_Symfony_Security_Proxy_Recaptcha - Fatal编程技术网

PHP-GoogleReCAPTCHA代理设置

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的PHP包装库。

我需要设置一个代理,但据我调查,这个库不支持代理配置

是否有人有机会成功为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();
}