1
1
# element_iot
2
+ #### included in PHP
2
3
###### Currently only GET Requests - updated soon
3
4
The PHP class makes it easy to access Zenner IoT's * ELEMENT IoT* platform.
4
5
It was builded for usage at [ Stadtwerke Karlsruhe GmbH] ( https://stadtwerke-karlsruhe.de ) , but can easily adapted
8
9
9
10
``` PHP
10
11
require "element_iot.inc.php";
11
- $element_iot = new element_iot("api_key_found_on_settings_api_keys ", "your.domain");//__construct($api_key, $domain)
12
+ $element_iot = new element_iot("api_key_found_on_settings->api_keys ", "your.domain", "proxy_if_needed" );//__construct($api_key, $domain = NULL, $proxy = NULL )
12
13
```
13
14
There is no need for declaring an Transfer Protocol.
14
15
It's always replaced with ** https://** !
15
16
The domain has a default value setted up for the usage at swka.
16
17
___
17
18
### Accessible Functions
19
+ #### get()
18
20
19
- In the first version are four accessible functions implemented.
21
+ In the first version are six accessible functions implemented.
20
22
I will list them in the following, with Parameters and description:
21
23
22
24
``` PHP
@@ -30,8 +32,26 @@ The *get* function starts an GET Request to the given domain and returns the ans
30
32
#### How to setup parameters?
31
33
32
34
( i ) * tp* stands for * type* and should define your request.
35
+ The configuration is the same as listed on the [ official api documentation] ( https://docs.element-iot.com/api/configuration/pagination/ ) .
36
+
37
+ ###### universal configuration
38
+ The Array is directly converted into the GET Request.
39
+ Pro: It's dynamic builded for the future.
40
+ * ** So use the key that you want to use as GET-Key as key for the Array and the GET-Value as Array value.**
41
+ ``` PHP
42
+ $configuration = [
43
+ "limit" => 10,
44
+ "sort" => "name",
45
+ "sort_direction" => "ascending",
46
+ "retrieve_after" => "ID of the last paginated item",
47
+ "before" => "YYYY-MM-DD",
48
+ "after" => "YYYY-MM-DD"
49
+ ]
50
+ ```
51
+
33
52
All currently possible possibilities are listed and explained in the following:
34
- ##### Devices
53
+
54
+ ##### Devices / Readings / Packets / Interfaces
35
55
``` PHP
36
56
$element_iot->get(["devices"]);
37
57
# Returns an array of all devices, filled up with information like: name, interfaces, etc. (without readings!)
@@ -47,21 +67,28 @@ The *get* function starts an GET Request to the given domain and returns the ans
47
67
# Returns an array of interfaces.
48
68
# > configuration
49
69
```
50
- ___
51
- ##### Devices
70
+ Configuration of: [ Devices] ( https://docs.element-iot.com/api/resources/devices/ ) |
71
+ Configuration of: [ Readings] ( https://docs.element-iot.com/api/resources/readings/ ) |
72
+ Configuration of: [ Packets] ( https://docs.element-iot.com/api/resources/packets/ ) |
73
+ Configuration of: [ Interfaces] ( https://docs.element-iot.com/api/resources/interfaces/ )
74
+
75
+ ##### Tags
52
76
``` PHP
53
77
$element_iot->get(["tags"]);
54
78
# Returns an array of tags.
55
79
# > configuration
56
80
```
57
- ___
81
+ Configuration of: [ Tags] ( https://docs.element-iot.com/api/resources/tags/ )
82
+
58
83
##### Parsers
59
84
``` PHP
60
85
$element_iot->get(["parsers"]);
61
86
# Returns an array of parsers.
62
87
# > configuration
63
88
```
64
- ___
89
+ Configuration of: [ Parsers] ( https://docs.element-iot.com/api/resources/parsers/ )
90
+
91
+
65
92
##### Drivers
66
93
``` PHP
67
94
$element_iot->get(["drivers"]); //returns an HTTP 500 Error at the current ELEMENT Version!
73
100
# > configuration
74
101
75
102
```
76
- ___
103
+ Configuration of: [ Drivers] ( https://docs.element-iot.com/api/resources/drivers/ ) |
104
+ Configuration of: [ Driver-Instances] ( https://docs.element-iot.com/api/resources/driver-instances/ )
105
+
77
106
##### Groups
78
107
``` PHP
79
108
$element_iot->get(["groups"]);
80
109
# Returns an array of groups.
81
110
# > configuration
82
111
```
83
- ___
112
+ Configuration of: [ Groups] ( https://docs.element-iot.com/api/resources/groups/ )
113
+
114
+
84
115
##### Api_keys
85
116
``` PHP
86
117
$element_iot->get(["api_keys"]);
87
118
# Returns an array of api_keys (if you are allowed to see them).
88
119
# > configuration
89
120
```
90
- ___
121
+ Configuration of: [ Api_keys] ( https://docs.element-iot.com/api/resources/api-keys/ )
122
+
123
+
91
124
##### Mandates
92
125
``` PHP
93
126
$element_iot->get(["mandates"]);
102
135
# > configuration
103
136
104
137
```
138
+ Configuration of: [ Mandates] ( https://docs.element-iot.com/api/resources/mandates/ ) |
139
+ Configuration of: [ stats / Statistics] ( https://docs.element-iot.com/api/resources/stats/ )
140
+ ___
141
+
142
+ #### set_api_key($api_key)
143
+ ``` PHP
144
+ $element_iot->set_api_key("you_new_api_key");
145
+ ```
146
+ Renew the API Key of an already initialized object.
147
+
148
+ #### get_api_key()
149
+ ``` PHP
150
+ $element_iot->set_api_key("you_new_api_key");
151
+ ```
152
+ Returns an String with the length of 32 characters, where 24 are * invisible* .
153
+ > For Identification if you use it for productiv systems with customers, etc.
154
+
155
+ #### get_cached_data()
156
+ ``` PHP
157
+ $element_iot->get_cached_data();
158
+ ```
159
+ Returns the answer of the last request.
160
+
161
+ #### set_domain($domain)
162
+ ``` PHP
163
+ $element_iot->set_domain("your_new_domain");
164
+ ```
165
+ Sets an new domain.
166
+
167
+ #### get_domain()
168
+ ``` PHP
169
+ $element_iot->get_domain();
170
+ ```
171
+ Returns the current domain.
172
+
173
+ ### How to Setup anything else?
174
+ If you want to setup curl you can do this or other defaults on the attributes in the class or an proxy can also set during the initialization of the object.
0 commit comments