Conditions | 1 |
Paths | 1 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public function save(array $data) |
||
15 | { |
||
16 | $json = json_encode($data); |
||
17 | |||
18 | $ch = curl_init($this->uri); |
||
19 | |||
20 | $headers = array( |
||
21 | 'Accept: application/json', // Prefer to receive JSON back |
||
22 | 'Content-Type: application/json' // The sent data is JSON |
||
23 | ); |
||
24 | |||
25 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
||
26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
27 | curl_setopt($ch, CURLOPT_POSTFIELDS, $json); |
||
28 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
||
29 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
||
30 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); |
||
31 | |||
32 | curl_exec($ch); |
||
33 | |||
34 | curl_close($ch); |
||
35 | } |
||
36 | } |
||
37 |