Problem with ReCaptcha and PHP

0

I have a problem with the ReCaptcha that I have inserted into my form.

I have verified that both the public and private keys are correctly written, the links are well placed, and I have reviewed the code of the 'recaptchalib.php' file that I downloaded from the google git repository. The domain that asks me in the administration of recaptcha is also well written.

In local I worked, but for some reason, now that my website is in the IIS, it does not work. As much as I verify that I am not a robot, I do not accept it.

Do I need a specific configuration to use it within the IIS?

Thank you very much.

EDITED

I've been fingering the code and apparently if I remove this part of:

if ($response != null && $response->success) {

a

 if ($response != null)

It works.

The $ response variable calls:

$response = $reCaptcha->verifyResponse(
     $_SERVER["REMOTE_ADDR"],
     $_POST["g-recaptcha-response"]
     );

And this in turn to the verifyResponse function of the recaptchalib.php file:

public function verifyResponse($remoteIp, $response)
{
    // Discard empty solution submissions
    if ($response == null || strlen($response) == 0) {
        $recaptchaResponse = new ReCaptchaResponse();
        $recaptchaResponse->success = false;
        $recaptchaResponse->errorCodes = 'missing-input';
        return $recaptchaResponse;
    }
    $getResponse = $this->_submitHttpGet(
        self::$_siteVerifyUrl,
        array (
            'secret' => $this->_secret,
            'remoteip' => $remoteIp,
            'v' => self::$_version,
            'response' => $response
        )
    );
    $answers = json_decode($getResponse, true);
    $recaptchaResponse = new ReCaptchaResponse();
    if (trim($answers ['success']) == true) {
        $recaptchaResponse->success = true;
    } else {
        $recaptchaResponse->success = false;
        $recaptchaResponse->errorCodes = $answers [error-codes];
    }
    return $recaptchaResponse;
}

Any idea where the problem is?

    
asked by Pelayo 14.02.2018 в 10:03
source

0 answers