forked from titansys/zender-gateways
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiara.php
61 lines (55 loc) · 1.67 KB
/
tiara.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Tiara SMS Platform
* @url https://meliora.co.ke/product/tiara
* @author MELIORA TECHNOLOGIES
*/
/**
* What is Tiara?
*
* Tiara SMS Gateway is a fast, simple, and secure enterprise SMS Gateway
* that simplifies how enterprises communicate to their customers via SMS.
*
* It supports various messaging protocols and simplifies SMS integrations.
*
* Multiple applications can connect to the gateway and the gateway can
* reliably route SMS traffic to multiple mobile network operators.
*/
define("TIARA_GATEWAY", [
"siteUrl" => "http://.....address/api/messaging/sendsms", // Meliora test SMS site url, don't add ending slash
"apiToken" => "", // Meliora test SMS client api token.
"senderId" => "" // The sender ID of the message.
]);
return [
"send" => function ($phone, $message, &$system) {
/**
* Implement sending here
* @return bool:true
* @return bool:false
*/
$send = json_decode($system->guzzle->post(TIARA_GATEWAY["siteUrl"], [
"headers" => [
"Authorization" => "Bearer " . TIARA_GATEWAY["apiToken"]
],
"json" => [
"to" => str_replace("+", "", $phone),
"from" => TIARA_GATEWAY["senderId"],
"message" => $message
],
"allow_redirects" => true,
"http_errors" => false
])->getBody()->getContents(), true);
try {
return isset($send["status"]) && strtolower($send["status"]) == "success" ? true : false;
} catch(Exception $e){
return false;
}
},
"callback" => function ($request, &$system) {
/**
* Implement status callback here if gateway supports it
* @return array:MessageID
* @return array:Empty
*/
}
];