Repository navigation
Expand file tree
/
Copy pathinboundSMSHandler.php
More file actions
43 lines (33 loc) · 1.63 KB
/
Copy pathinboundSMSHandler.php
File metadata and controls
43 lines (33 loc) · 1.63 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
<?php
// Incoming Voice number thats paired with this setup – used for voice Conferences etc.
$voiceNumber = “+1…”;
// Get the Variables from the HTTP POST, We want to know the BODY and the FROM so we can authorise and action the request.
$fromPhoneNumber = $_POST["From"];
$messageBody = $_POST["Body"];
// Check the phone number is on our authorised list if so action the SMS request.
// As this grows you want to put the numbers into an authorised DB and make a DB request regarding this.
// As this minute we are just going to look up against authorised number just in the IF field.
if ($fromPhoneNumber == “+1…” or “+44…”) // This is the list of authorised numbers that can make conf rooms.
{
// If the number is authorised then we are going to look at the body for what we need to make / do.
if ($messageBody == “Conference” or “Conf”)
{
// If the body is Conference we want to generate a 4 digit pin number and then generate a SMS message that can be
// forwarded out to the participants.
// The idea is that this script will reply with
// “A Conference has been setup, please call XYZ Number and enter pin 1234”
$confPin = rand(1000, 9999); // Generate a random pin number
$TwiMLResponse = “<Message>Conference Room Details:\r\nPhone Number: ” . $voiceNumber . “\r\nConference Pin: ” . $confPin. “</Message>”;
}
else // Catch all for whats left.
{
$TwiMLResponse = “<Message>Sorry, Me No understand. Try Again.</Message>”;
}
}
else
{
$TwiMLResponse = “<Message>Sorry, Your not authorised for this.</Message>”;
}
header(“content-type: text/xml”);
?>
<Response><?php echo $TwiMLResponse; ?></Response>