/** * Check Response with form data * * @param $formData * @return array */ public function check($formData) { $ch = curl_init(); $timeout = 5; $url = $this->config->getRequestUrl() . '?secret=' . $this->config->getSecretKey() . '&response=' . $formData . "&remoteip=" . $_SERVER['REMOTE_ADDR']; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); if (!curl_errno($ch)) { $googleResponse = curl_exec($ch); $googleResponse = json_decode($googleResponse); if ($googleResponse->status == true) { $response = ['status' => true, 'message' => 'Checked']; } else { $response = ['status' => false, 'message' => 'Captcha security code is not valid']; } } else { $response = ['status' => false, 'message' => 'Curl error: ' . curl_error($ch)]; } curl_close($ch); return $response; }