Verifies a reCAPTCHA response with Google’s API.
Description
See also
Parameters
- $response
-
(string) (Required) reCAPTCHA response input.
Return
(string) Raw response as a JSON-formatted string.
Source
File: src/modules/protectors/recaptcha.php
protected function verify_response_input( $response ) { $peer_key = version_compare( phpversion(), '5.6.0', '<' ) ? 'CN_name' : 'peer_name'; $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query( array( 'secret' => $this->get_option( 'secret_key' ), 'response' => $response, ), '', '&' ), 'verify_peer' => true, $peer_key => 'www.google.com', ), ); $context = stream_context_create( $options ); return file_get_contents( 'https://www.google.com/recaptcha/api/siteverify', false, $context ); }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |