# fluentform/6.2.3/app/Modules/HCaptcha/HCaptcha.php

Fluent Forms – Customizable Contact Forms, Survey, Quiz, &amp; Conversational Form Builder, version 6.2.3. 41 lines.

- Page: https://pluginprobe.com/plugins/fluentform/6.2.3/code/app/Modules/HCaptcha/HCaptcha.php
- Raw: https://pluginprobe.com/plugins/fluentform/6.2.3/raw/app/Modules/HCaptcha/HCaptcha.php
- Modified: 2022-10-16T13:42:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluentform/6.2.3/code/app/Modules/HCaptcha/HCaptcha.php#L10-L20`.

```php
<?php

namespace FluentForm\App\Modules\HCaptcha;

use FluentForm\Framework\Helpers\ArrayHelper;

class HCaptcha
{
    /**
     * Verify hCaptcha response.
     *
     * @param string $token  response from the user.
     * @param null   $secret provided or already stored secret key.
     *
     * @return bool
     */
    public static function validate($token, $secret = null)
    {
        $verifyUrl = 'https://hcaptcha.com/siteverify';

        $secret = $secret ?: ArrayHelper::get(get_option('_fluentform_hCaptcha_details'), 'secretKey');

        $response = wp_remote_post($verifyUrl, [
            'method' => 'POST',
            'body'   => [
                'secret'   => $secret,
                'response' => $token,
            ],
        ]);

        $isValid = false;

        if (!is_wp_error($response)) {
            $result = json_decode(wp_remote_retrieve_body($response));
            $isValid = $result->success;
        }

        return $isValid;
    }
}

```
