summaryrefslogtreecommitdiff
path: root/includes/recaptcha/ReCaptcha/RequestMethod/CurlPost.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/recaptcha/ReCaptcha/RequestMethod/CurlPost.php')
-rw-r--r--includes/recaptcha/ReCaptcha/RequestMethod/CurlPost.php98
1 files changed, 49 insertions, 49 deletions
diff --git a/includes/recaptcha/ReCaptcha/RequestMethod/CurlPost.php b/includes/recaptcha/ReCaptcha/RequestMethod/CurlPost.php
index 1bd7cce..fc993d8 100644
--- a/includes/recaptcha/ReCaptcha/RequestMethod/CurlPost.php
+++ b/includes/recaptcha/ReCaptcha/RequestMethod/CurlPost.php
@@ -45,60 +45,60 @@ use ReCaptcha\RequestParameters;
*/
class CurlPost implements RequestMethod
{
- /**
- * Curl connection to the reCAPTCHA service
- * @var Curl
- */
- private $curl;
+ /**
+ * Curl connection to the reCAPTCHA service
+ * @var Curl
+ */
+ private $curl;
- /**
- * URL for reCAPTCHA siteverify API
- * @var string
- */
- private $siteVerifyUrl;
+ /**
+ * URL for reCAPTCHA siteverify API
+ * @var string
+ */
+ private $siteVerifyUrl;
- /**
- * Only needed if you want to override the defaults
- *
- * @param Curl $curl Curl resource
- * @param string $siteVerifyUrl URL for reCAPTCHA siteverify API
- */
- public function __construct(Curl $curl = null, $siteVerifyUrl = null)
- {
- $this->curl = (is_null($curl)) ? new Curl() : $curl;
- $this->siteVerifyUrl = (is_null($siteVerifyUrl)) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
- }
+ /**
+ * Only needed if you want to override the defaults
+ *
+ * @param Curl $curl Curl resource
+ * @param string $siteVerifyUrl URL for reCAPTCHA siteverify API
+ */
+ public function __construct(Curl $curl = null, $siteVerifyUrl = null)
+ {
+ $this->curl = (is_null($curl)) ? new Curl() : $curl;
+ $this->siteVerifyUrl = (is_null($siteVerifyUrl)) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
+ }
- /**
- * Submit the cURL request with the specified parameters.
- *
- * @param RequestParameters $params Request parameters
- * @return string Body of the reCAPTCHA response
- */
- public function submit(RequestParameters $params)
- {
- $handle = $this->curl->init($this->siteVerifyUrl);
+ /**
+ * Submit the cURL request with the specified parameters.
+ *
+ * @param RequestParameters $params Request parameters
+ * @return string Body of the reCAPTCHA response
+ */
+ public function submit(RequestParameters $params)
+ {
+ $handle = $this->curl->init($this->siteVerifyUrl);
- $options = array(
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $params->toQueryString(),
- CURLOPT_HTTPHEADER => array(
- 'Content-Type: application/x-www-form-urlencoded'
- ),
- CURLINFO_HEADER_OUT => false,
- CURLOPT_HEADER => false,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_SSL_VERIFYPEER => true
- );
- $this->curl->setoptArray($handle, $options);
+ $options = [
+ CURLOPT_POST => true,
+ CURLOPT_POSTFIELDS => $params->toQueryString(),
+ CURLOPT_HTTPHEADER => [
+ 'Content-Type: application/x-www-form-urlencoded',
+ ],
+ CURLINFO_HEADER_OUT => false,
+ CURLOPT_HEADER => false,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_SSL_VERIFYPEER => true,
+ ];
+ $this->curl->setoptArray($handle, $options);
- $response = $this->curl->exec($handle);
- $this->curl->close($handle);
+ $response = $this->curl->exec($handle);
+ $this->curl->close($handle);
- if ($response !== false) {
- return $response;
- }
+ if ($response !== false) {
+ return $response;
+ }
- return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
- }
+ return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
+ }
}