-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleGDMSClient.php
More file actions
80 lines (64 loc) · 2.68 KB
/
SampleGDMSClient.php
File metadata and controls
80 lines (64 loc) · 2.68 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/*
* PHP SDK for GDMS (Grandstream Device Management System) API
*
* Copyright (C) 2022, Naveen Albert
*
* GDMS (Grandstream Device Management System) is a trademark of Grandstream Networks, Inc.
* This project is not in any way affiliated with Grandstream Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Include the GDMS class */
require_once('GDMS.php');
/* TODO: Replace these with your information */
$apiID = 100555; /* 6-digit GDMS Developer API ID */
$secretKey = 'UYURsdf898fDF3e8f7dusf89dsgfgsdf'; /* 32-character GDMS secret key */
$username = 'jsmith'; /* Your GDMS account username */
$password = 'p@ssw0rd'; /* Your GDMS account password */
$passwordHash = hash("sha256", md5($password)); /* Don't be fooled, using a password hash is NOT more secure than just your password. Protect it. */
$gdms = new GDMS($apiID, $secretKey, $username, $passwordHash);
$gdms->setDebug(true);
$gdms->login();
/* Get organizations */
$resp = $gdms->organizationList();
print_r($resp['data']['result']);
/* Get sites in default organization */
$resp = $gdms->siteList();
print_r($resp['data']['result']);
/* Print all devices: print_r($resp['data']['result']); */
$resp = $gdms->deviceList();
echo "You have " . count($resp['data']['result']) . " devices\n";
/* Get account statuses */
$resp = $gdms->deviceAccountStatus('00AABBCCDDFF');
print_r($resp);
/* Get account configs */
$resp = $gdms->deviceAccountConfig('00AABBCCDDFF');
print_r($resp);
/* Add a device to GDMS */
/* Note: The MAC address can contain colons or not. Up to you. */
$resp = $gdms->addDevice('00AABBCCDDFF', '207GHQXG70CCDDFF', 12345, '', 45789);
print_r($resp);
/* View the current details (yes, using the editDevice function) */
$resp = $gdms->editDevice('00AABBCCDDFF', '207GHQXG70CCDDFF', 12345, '', 45789);
print_r($resp);
/* View the current details, if the device is offline. Avoid this API and use getDevice() instead if possible. */
$resp = $gdms->deviceDetails('00AABBCCDDFF', 0);
print_r($resp);
/* Reboot the ATA */
$resp = $gdms->deviceReboot('00AABBCCDDFF');
print_r($resp);
/* View details about the ATA. This works even when it's not online. */
$resp = $gdms->getDevice('00AABBCCDDFF');
print_r($resp);
?>