forked from JaniKibichi/microfinance-ussd-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
voiceCall.php
executable file
·35 lines (26 loc) · 1.16 KB
/
voiceCall.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
<?php
// This is a unique ID generated for this call
$sessionId = $_POST['sessionId'];
$isActive = $_POST['isActive'];
if ($isActive == 1) {
$callerNumber = $_POST['callerNumber'];
// Compose the response
$response = '<?xml version="1.0" encoding="UTF-8"?>';
$response .= '<Response>';
$response .= '<GetDigits timeout="30" finishOnKey="#" callbackUrl="http://62.12.117.25/MF-Ussd-Live/voiceMenu.php">';
$response .= '<Say>"Thank you for calling. Press 0 to talk to sales, 1 to talk to support or 2 to hear this message again."</Say>';
$response .= '</GetDigits>';
$response .= '<Say>"Thank you for calling. Good bye!"</Say>';
$response .= '</Response>';
// Print the response onto the page so that our gateway can read it
header('Content-type: text/plain');
echo $response;
} else {
// Read in call details (duration, cost). This flag is set once the call is completed.
// Note that the gateway does not expect a response in thie case
$duration = $_POST['durationInSeconds'];
$currencyCode = $_POST['currencyCode'];
$amount = $_POST['amount'];
// You can then store this information in the database for your records
}
?>