1 | <?php |
||
5 | class Curl implements CurlInterface |
||
6 | { |
||
7 | private $curl; |
||
8 | |||
9 | /** |
||
10 | * @param string $url |
||
11 | * @param resource $curl to inject an external curl_id (returned by curl_init)... for testing or whatever |
||
12 | */ |
||
13 | 5 | public function __construct($url, $curl = null) |
|
14 | { |
||
15 | 5 | $this->curl = $curl ? $curl : curl_init(); |
|
16 | 5 | curl_setopt($this->curl, CURLOPT_URL, $url); |
|
17 | |||
18 | 5 | curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false); |
|
19 | 5 | curl_setopt($this->curl, CURLOPT_TIMEOUT, 15); |
|
20 | 5 | curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); |
|
21 | 5 | } |
|
22 | |||
23 | /** |
||
24 | * @param array $posts |
||
25 | */ |
||
26 | 1 | public function setPosts(array $posts) |
|
31 | |||
32 | /** |
||
33 | * Write the response to a file |
||
34 | * |
||
35 | * @param string $filename |
||
36 | */ |
||
37 | 1 | public function setOutput($filename) |
|
41 | |||
42 | /** |
||
43 | * @return mixed |
||
44 | * @throws \Exception |
||
45 | */ |
||
46 | 4 | public function getResponse() |
|
58 | } |
||
59 |