diff options
author | bjoernr-de <bjoern.roland@gmail.com> | 2015-03-27 20:11:45 +0100 |
---|---|---|
committer | bjoernr-de <bjoern.roland@gmail.com> | 2015-03-27 20:11:45 +0100 |
commit | 3130e3cbf7a86517bfa8b935c3eb6f5a4614406e (patch) | |
tree | 081b2e75f8c4e3f4ac104d2626797640ce8418ed /sslLabsApi.php | |
parent | 3a77a11a6d2d3f15d4c78d99a5b4acc5e5226c95 (diff) | |
download | php-ssllabs-api-3130e3cbf7a86517bfa8b935c3eb6f5a4614406e.zip php-ssllabs-api-3130e3cbf7a86517bfa8b935c3eb6f5a4614406e.tar.gz php-ssllabs-api-3130e3cbf7a86517bfa8b935c3eb6f5a4614406e.tar.bz2 |
Add possibilty to return API response as JSON object
Diffstat (limited to 'sslLabsApi.php')
-rw-r--r-- | sslLabsApi.php | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/sslLabsApi.php b/sslLabsApi.php index f0c5e8d..32f3d4e 100644 --- a/sslLabsApi.php +++ b/sslLabsApi.php @@ -14,6 +14,16 @@ class sslLabsApi { CONST API_URL = "https://api.ssllabs.com/api/v2"; + private $returnJsonObjects; + + /** + * sslLabsApi::__construct() + */ + public function __construct($returnJsonObjects = false) + { + $this->returnJsonObjects = (boolean) $returnJsonObjects; + } + /** * sslLabsApi::fetchApiInfo() * @@ -135,7 +145,39 @@ class sslLabsApi ) ); - return (file_get_contents(self::API_URL . '/' . $apiCall . $this->buildGetParameterString($parameters), false, $context)); + $apiResponse = file_get_contents(self::API_URL . '/' . $apiCall . $this->buildGetParameterString($parameters), false, $context); + + if($this->returnJsonObjects) + { + return (json_decode($apiResponse)); + } + + return ($apiResponse); + } + + /** + * sslLabsApi::setReturnJsonObjects() + * + * Setter for returnJsonObjects + * Set true to return all API responses as JSON object, false returns it as simple JSON strings (default) + * + * @param boolean $returnJsonObjects + */ + public function setReturnJsonObjects($returnJsonObjects) + { + $this->returnJsonObjects = (boolean) $returnJsonObjects; + } + + /** + * sslLabsApi::getReturnJsonObjects() + * + * Getter for returnJsonObjects + * + * @return boolean true returns all API responses as JSON object, false returns it as simple JSON string + */ + public function getReturnJsonObjects() + { + return ($this->returnJsonObjects); } /** |