google recaptcha varification in php codeigniter

// Step 1: Load Recaptcha library in your controller
$this->load->library('recaptcha');

// Step 2: Get the site and secret keys from Google Recaptcha
$siteKey = 'YOUR_SITE_KEY';
$secretKey = 'YOUR_SECRET_KEY';

// Step 3: Set the keys in the Recaptcha library
$this->recaptcha->setKeys($siteKey, $secretKey);

// Step 4: Verify Recaptcha response in your form validation
$this->form_validation->set_rules('g-recaptcha-response', 'Recaptcha', 'required|callback_verify_recaptcha');

// Step 5: Define a callback function to verify Recaptcha
public function verify_recaptcha($response) {
    $recaptchaResult = $this->recaptcha->verifyResponse($response);

    if ($recaptchaResult['success']) {
        return true;
    } else {
        $this->form_validation->set_message('verify_recaptcha', 'Recaptcha verification failed.');
        return false;
    }
}

// Step 6: Use the Recaptcha widget in your form view
echo $this->recaptcha->getWidget();

// Step 7: Optionally, display Recaptcha errors in your form
echo validation_errors();

Make sure to replace 'YOUR_SITE_KEY' and 'YOUR_SECRET_KEY' with your actual Google Recaptcha keys.