forked from tomrosenback/botvac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NeatoBotvacApi.php
41 lines (31 loc) · 944 Bytes
/
NeatoBotvacApi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
* Neato Botvac Api.
* Helper class to make requests against Neato API
*
* PHP port based on https://github.com/kangguru/botvac
*
* Author: Tom Rosenback [email protected] 2016
*/
class NeatoBotvacApi {
public static function request($url, $payload = array(), $method = "POST", $headers = array()) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
if($method == "POST") {
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
}
$requestHeaders = array(
'Accept: application/vnd.neato.nucleo.v1'
);
if(count($headers) > 0) {
$requestHeaders = array_merge($requestHeaders, $headers);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
}