/
santa.php
48 lines (40 loc) · 1.27 KB
/
santa.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
<?php
require_once(__DIR__."/includes/AfricasTalkingGateway.php");
require_once(__DIR__."/includes/utils.php");
//get some post data
$callerNumber = $_POST['callerNumber'];
$direction = $_POST['direction'];
$sessionID = $_POST['sessionId'];
$isCallActive = $_POST['isActive'];
if ($isCallActive == 1 && $direction == "Inbound") {
//hang up
//construct response
$response = '<?xml version="1.0" encoding="UTF-8"?>';
$response .= '<Response>';
$response .= '<Reject/>';
$response .= '</Response>';
header('Content-type: text/plain');
echo $response;
//immediately call user back
$gateway = new AfricasTalkingGateway($aitusername, $aitkey);
try {
$gateway->call($aitnumber, $callerNumber);
} catch (Exception $e) {
echo "error: ".$e->getMessage();
}
}
elseif ($isCallActive == 1 && $direction == "Outbound") {
//redirect call to be processed on other page
$url = "https://santa-slybard.c9users.io/wishlist.php";
//construct response
$response = '<?xml version="1.0" encoding="UTF-8"?>';
$response .= '<Response>';
$response .= '<Redirect>'.$url.'</Redirect>';
$response .= '</Response>';
header('Content-type: text/plain');
echo $response;
}
else{
SendResponse(false, "Goodbye!");
}
?>