Devices-Übersicht:
* Anzeige des Backupstatus (OK,älter als 48 Stunden, kein Backup vorhanden)
DeviceApicontroller:
* Update Devices hinzugefügt (nur last_config_backup update erlaubt)
Funktionsweise:
Sobald eine Config am API Server registriert wird, wird per API Richtung Tool der Timestamp der Config in der Tool-DB geupdated
Somit ist für die Übersicht keine direkte API Schnittstelle notwendig.
SmsNotification Klasse hinzugefügt.
Habs gleich wie die Emailnotification gehalten.
Ist zum puschen von SMSen an ein Absenderarray oder Einzelabsender.
Erfüllt in dem Commit noch keine Funktion.
Config Erweiterungen:
define("TT_OUTGOING_SMS_API_KEY", "key");
define("TT_OUTGOING_SMS_API_URL", "api.websms.com/rest");
This commit is contained in:
56
application/SmsNotification/SmsNotification.php
Normal file
56
application/SmsNotification/SmsNotification.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class SmsNotification
|
||||
{
|
||||
private $ApiKey;
|
||||
private $ApiUrl;
|
||||
private $body;
|
||||
private $recipient;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->ApiKey = TT_OUTGOING_SMS_API_KEY;
|
||||
$this->ApiUrl = TT_OUTGOING_SMS_API_URL;
|
||||
}
|
||||
|
||||
|
||||
public function setBody($body)
|
||||
{
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
public function setRecipient($recipient)
|
||||
{
|
||||
if (is_array($recipient)) {
|
||||
$this->recipient = implode(",", $recipient);
|
||||
} else {
|
||||
$this->recipient = $recipient;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function send()
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $this->ApiUrl . '/smsmessaging/simple',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => array('messageContent' => $this->body, 'recipientAddressList' => $this->recipient),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer ' . $this->ApiKey
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
echo $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user