forked from titansys/zender-gateways
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwilio.php
More file actions
49 lines (44 loc) · 1.21 KB
/
twilio.php
File metadata and controls
49 lines (44 loc) · 1.21 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
<?php
/**
* Twilio SMS Gateway
* @author Titan Systems
*/
define("TWILIO_GATEWAY", [
"fromNumber" => "", // Your twilio phone number
"accountSid" => "", // Your twilio Account SID
"authToken" => "" // Your twilio authentication token
]);
return [
"send" => function ($phone, $message, &$system) {
/**
* Implement sending here
* @return bool:true
* @return bool:false
*/
$send = json_decode($system->guzzle->post("https://api.twilio.com/2010-04-01/Accounts/" . TWILIO_GATEWAY["accountSid"] . "/Messages.json", [
"form_params" => [
"From" => TWILIO_GATEWAY["fromNumber"],
"Body" => $message,
"To" => $phone
],
"auth" => [
TWILIO_GATEWAY["accountSid"],
TWILIO_GATEWAY["authToken"]
],
"allow_redirects" => true,
"http_errors" => false
])->getBody()->getContents());
if(in_array($send->status, ["accepted", "queued"])):
return true;
else:
return false;
endif;
},
"callback" => function ($request, &$system) {
/**
* Implement status callback here if gateway supports it
* @return array:MessageID
* @return array:Empty
*/
}
];