protected function validateValue($value)
{
if (empty($value)) {
if (!($value = Yii::$app->request->post(self::CAPTCHA_RESPONSE_FIELD))) {
return [$this->message, []];
}
}
$request = self::SITE_VERIFY_URL . '?' . http_build_query(['secret' => $this->secret, 'response' => $value, 'remoteip' => Yii::$app->request->userIP]);
$response = $this->getResponse($request);
if (!isset($response['success'])) {
throw new Exception('Invalid recaptcha verify response.');
}
return $response['success'] ? null : [$this->message, []];
}