diff --git a/src/main/resources/php/Swagger.mustache b/src/main/resources/php/Swagger.mustache index efa2ecb0fde..962cc53455f 100644 --- a/src/main/resources/php/Swagger.mustache +++ b/src/main/resources/php/Swagger.mustache @@ -28,6 +28,8 @@ class APIClient { public static $PUT = "PUT"; public static $DELETE = "DELETE"; + private $curl_timout = 5; + /** * @param string $apiKey your API key * @param string $apiServer the address of the API server @@ -37,6 +39,16 @@ class APIClient { $this->apiServer = $apiServer; } + /** + * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] + */ + public function setTimeout($seconds) { + if (!is_numeric($seconds)) { + throw new Exception('Timeout variable must be numeric.'); + } + $this->curl_timout = $seconds; + } + /** * @param string $resourcePath path to method endpoint @@ -72,7 +84,9 @@ class APIClient { $url = $this->apiServer . $resourcePath; $curl = curl_init(); - curl_setopt($curl, CURLOPT_TIMEOUT, 5); + if ($this->curl_timout) { + curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout); + } // return the result on success, rather than just TRUE curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); diff --git a/src/main/resources/php/api.mustache b/src/main/resources/php/api.mustache index 9d3e59fc63b..30d34f556e7 100644 --- a/src/main/resources/php/api.mustache +++ b/src/main/resources/php/api.mustache @@ -77,6 +77,8 @@ class {{classname}} { {{/formParams}} if (empty($body)) { $body = null; + } else if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { + $body = http_build_query($body); } // Make the API Call