From b701c866b03744173424b5a4304c2d324ef56e2f Mon Sep 17 00:00:00 2001 From: Marce Romagnoli Date: Fri, 3 Oct 2014 15:29:51 -0300 Subject: [PATCH] Add connection and response timeout options. --- src/indeed.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/indeed.php b/src/indeed.php index 5711f33..76d81e0 100644 --- a/src/indeed.php +++ b/src/indeed.php @@ -1,6 +1,6 @@ publisher = $publisher; $this->version = $version; + $this->timeout = $timeout; } public function search($args){ @@ -32,6 +33,8 @@ private function process_request($endpoint, $args){ $args["format"] = $format; $c = curl_init(sprintf("%s?%s", $endpoint, http_build_query($args))); curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($c, CURLOPT_CONNECTTIMEOUT, $this->timeout); + curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout); $result = curl_exec($c); curl_close($c); $r = (!$raw ? json_decode($result, $assoc = true) : $result); @@ -58,4 +61,4 @@ private function validate_args($required_fields, $args){ return $args; } -} \ No newline at end of file +}