Userprofile Implementierung Datatables Padding Anpassungen Usercontroller und User um Mobile erweitert
65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?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);
|
|
$exploderesponse = explode("&", $response);
|
|
foreach ($exploderesponse as $value) {
|
|
$explode = explode("=", $value);
|
|
if (count($explode) == 2) {
|
|
$responsedata['data'][$explode[0]] = $explode[1];
|
|
}
|
|
}
|
|
|
|
curl_close($curl);
|
|
return $responsedata;
|
|
}
|
|
|
|
}
|
|
|