@@ -28,6 +28,8 @@ class APIClient {
28
28
public static $PUT = " PUT" ;
29
29
public static $DELETE = " DELETE" ;
30
30
31
+ private $curl_timout = 5;
32
+
31
33
/**
32
34
* @param string $apiKey your API key
33
35
* @param string $apiServer the address of the API server
@@ -37,6 +39,16 @@ class APIClient {
37
39
$this -> apiServer = $apiServer ;
38
40
}
39
41
42
+ /**
43
+ * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
44
+ */
45
+ public function setTimeout($seconds) {
46
+ if (! is_numeric($seconds )) {
47
+ throw new Exception(' Timeout variable must be numeric.' );
48
+ }
49
+ $this->curl_timout = $seconds;
50
+ }
51
+
40
52
41
53
/**
42
54
* @param string $resourcePath path to method endpoint
@@ -72,7 +84,9 @@ class APIClient {
72
84
$url = $this->apiServer . $resourcePath;
73
85
74
86
$curl = curl_init();
75
- curl_setopt($curl, CURLOPT_TIMEOUT, 5);
87
+ if ($this->curl_timout) {
88
+ curl_setopt($curl , CURLOPT_TIMEOUT, $this -> curl_timout );
89
+ }
76
90
// return the result on success, rather than just TRUE
77
91
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
78
92
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
0 commit comments