-
Notifications
You must be signed in to change notification settings - Fork 13
/
telnyx.php
49 lines (44 loc) · 1.19 KB
/
telnyx.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
<?php
/**
* Telnyx SMS Gateway
* @author Titan Systems
*/
define("TELNYX_GATEWAY", [
"apikey" => "KEY018423367F8AHJS71A7A74EDB6C20F25_of4tdzcVXFptkszhkjdsd7", // Your telnyx api key
"from" => "+13642220854", // Your telnyx phone number
]);
return [
"send" => function ($phone, $message, &$system) {
/**
* Implement sending here
* @return bool:true
* @return bool:false
*/
try {
$send = $system->guzzle->post("https://api.telnyx.com/v2/messages", [
"headers" => [
"Accept" => "application/json",
"Content-Type" => "application/json",
"Authorization" => "Bearer " . TELNYX_GATEWAY["apikey"]
],
"json" => [
"from" => TELNYX_GATEWAY["from"],
"to" => $phone,
"text" => $message
],
"allow_redirects" => true,
"http_errors" => false
]);
return $send->getStatusCode() == 200 ? 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
*/
}
];