protected function _postHttpChallenge(array $data)
	{
		if ( strlen($this->_privateKey) == 0 ) {
			throw new CaptchaException(
				'To use reCAPTCHA you must get a Private API key from https://www.google.com/recaptcha/admin'
			);
		}

		$responseHeader = '';
		$result = array('isvalid'=>'false', 'error'=>'');

		$remote_url = parse_url(self::RECAPTCHA_VERIFY_SERVER);
		$httpQuery  = http_build_query($data);

		$requestHeader  = sprintf(
			self::RECAPTCHA_HEADER,
			$remote_url['path'],
			$remote_url['host'],
			strlen($httpQuery),
			$httpQuery);

		if ( function_exists('fsockopen') ) {

			$handler = @fsockopen($remote_url['host'], 80, $errno, $errstr, $this->timeout);

			if( false == ( $handler ) ) {
				throw new CaptchaException(
					sprintf('Could not open sock to check reCAPTCHA at %s.', self::RECAPTCHA_VERIFY_SERVER)
				);
			}

			stream_set_timeout($handler, $this->timeout);

			fwrite($handler, $requestHeader);

			$remote_response = stream_get_line($handler, 32, "\n");

			if (strpos($remote_response, '200 OK') !== false) {

				while (!feof($handler)) {
					$responseHeader .= stream_get_line($handler, 356);
				}
				fclose($handler);

				$responseHeader = str_replace("\r\n", "\n", $responseHeader);
				$responseHeader = explode("\n\n", $responseHeader);
				array_shift($responseHeader);

				$responseHeader = explode("\n", implode("\n\n", $responseHeader));
			}

	  	// Fallback to CURL if fsockopen is not enabled
		} elseif ( extension_loaded('curl') ) {

			$ch = curl_init(self::RECAPTCHA_VERIFY_SERVER);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
			curl_setopt($ch, CURLOPT_USERAGENT, 'reCAPTCHA/PHP');
			curl_setopt($ch, CURLOPT_HTTPHEADER, explode("\r\n", $requestHeader) );
			curl_setopt($ch, CURLOPT_HEADER, false);
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $httpQuery);

			$responseHeader = curl_exec($ch);

			curl_close($ch);

			if ($responseHeader !== false) {

				$responseHeader = explode("\n\n", $responseHeader);
				$responseHeader = explode("\n", implode("\n\n", $responseHeader));
			}

		} else {
			throw new CaptchaException(
				sprintf('Can\'t connect to the server %s. Try again.', self::RECAPTCHA_VERIFY_SERVER )
			);
		}

		$result = ( count($responseHeader) == 2 )
			? array_combine(array_keys($result), $responseHeader)
			: $result;

		return $result;
	}
protected function _postHttpChallenge(array $data)
	{
		if ( strlen($this->_privateKey) == 0 ) {
			throw new CaptchaException(
				'To use reCAPTCHA you must get a Private API key from https://www.google.com/recaptcha/admin'
			);
		}

		$responseHeader = '';
		$result = array('isvalid'=>'false', 'error'=>'');

		$remote_url = parse_url(self::RECAPTCHA_VERIFY_SERVER);
		$httpQuery  = http_build_query($data);

		$requestHeader  = sprintf(
			self::RECAPTCHA_HEADER,
			$remote_url['path'],
			$remote_url['host'],
			strlen($httpQuery),
			$httpQuery);

		if ( function_exists('fsockopen') ) {

			$handler = @fsockopen($remote_url['host'], 80, $errno, $errstr, $this->timeout);

			if( false == ( $handler ) ) {
				throw new CaptchaException(
					sprintf('Could not open sock to check reCAPTCHA at %s.', self::RECAPTCHA_VERIFY_SERVER)
				);
			}

			stream_set_timeout($handler, $this->timeout);

			fwrite($handler, $requestHeader);

			$remote_response = stream_get_line($handler, 32, "\n");

			if (strpos($remote_response, '200 OK') !== false) {

				while (!feof($handler)) {
					$responseHeader .= stream_get_line($handler, 356);
				}
				fclose($handler);

				$responseHeader = str_replace("\r\n", "\n", $responseHeader);
				$responseHeader = explode("\n\n", $responseHeader);
				array_shift($responseHeader);

				$responseHeader = explode("\n", implode("\n\n", $responseHeader));
			}

	  	// Fallback to CURL if fsockopen is not enabled
		} elseif ( extension_loaded('curl') ) {

			$ch = curl_init(self::RECAPTCHA_VERIFY_SERVER);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
			curl_setopt($ch, CURLOPT_USERAGENT, 'reCAPTCHA/PHP');
			curl_setopt($ch, CURLOPT_HTTPHEADER, explode("\r\n", $requestHeader) );
			curl_setopt($ch, CURLOPT_HEADER, false);
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $httpQuery);

			$responseHeader = curl_exec($ch);

			curl_close($ch);

			if ($responseHeader !== false) {

				$responseHeader = explode("\n\n", $responseHeader);
				$responseHeader = explode("\n", implode("\n\n", $responseHeader));
			}

		} else {
			throw new CaptchaException(
				sprintf('Can\'t connect to the server %s. Try again.', self::RECAPTCHA_VERIFY_SERVER )
			);
		}

		$result = ( count($responseHeader) == 2 )
			? array_combine(array_keys($result), $responseHeader)
			: $result;

		return $result;
	}
protected function _postHttpChallenge ( array $ data ) { if ( strlen ( $ this -> _privateKey ) == 0 ) { throw new CaptchaException ( 'To use reCAPTCHA you must get a Private API key from https://www.google.com/recaptcha/admin' ) ; } $ responseHeader = '' ; $ result = array ( 'isvalid' => 'false' , 'error' => '' ) ; $ remote_url = parse_url ( self :: RECAPTCHA_VERIFY_SERVER ) ; $ httpQuery = http_build_query ( $ data ) ; $ requestHeader = sprintf ( self :: RECAPTCHA_HEADER , $ remote_url [ 'path' ] , $ remote_url [ 'host' ] , strlen ( $ httpQuery ) , $ httpQuery ) ; if ( function_exists ( 'fsockopen' ) ) { $ handler = @ fsockopen ( $ remote_url [ 'host' ] , 80 , $ errno , $ errstr , $ this -> timeout ) ; if ( false == ( $ handler ) ) { throw new CaptchaException ( sprintf ( 'Could not open sock to check reCAPTCHA at %s.' , self :: RECAPTCHA_VERIFY_SERVER ) ) ; } stream_set_timeout ( $ handler , $ this -> timeout ) ; fwrite ( $ handler , $ requestHeader ) ; $ remote_response = stream_get_line ( $ handler , 32 , "\n" ) ; if ( strpos ( $ remote_response , '200 OK' ) !== false ) { while ( ! feof ( $ handler ) ) { $ responseHeader .= stream_get_line ( $ handler , 356 ) ; } fclose ( $ handler ) ; $ responseHeader = str_replace ( "\r\n" , "\n" , $ responseHeader ) ; $ responseHeader = explode ( "\n\n" , $ responseHeader ) ; array_shift ( $ responseHeader ) ; $ responseHeader = explode ( "\n" , implode ( "\n\n" , $ responseHeader ) ) ; } // Fallback to CURL if fsockopen is not enabled } elseif ( extension_loaded ( 'curl' ) ) { $ ch = curl_init ( self :: RECAPTCHA_VERIFY_SERVER ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , $ this -> timeout ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , 'reCAPTCHA/PHP' ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , explode ( "\r\n" , $ requestHeader ) ) ; curl_setopt ( $ ch , CURLOPT_HEADER , false ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ httpQuery ) ; $ responseHeader = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; if ( $ responseHeader !== false ) { $ responseHeader = explode ( "\n\n" , $ responseHeader ) ; $ responseHeader = explode ( "\n" , implode ( "\n\n" , $ responseHeader ) ) ; } } else { throw new CaptchaException ( sprintf ( 'Can\'t connect to the server %s. Try again.' , self :: RECAPTCHA_VERIFY_SERVER ) ) ; } $ result = ( count ( $ responseHeader ) == 2 ) ? array_combine ( array_keys ( $ result ) , $ responseHeader ) : $ result ; return $ result ; }
reCAPTCHA API Request

Post reCAPTCHA input challenge, response
Uses function fsockopen() and curl() as a fallback
If both functions are unavailable in server configuration
an {@link \ReCaptcha\CaptchaException} exception will be thrown

@param array $data Array of reCAPTCHA parameters
@throws \ReCaptcha\CaptchaException
@return array
reCAPTCHA API Request