-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathussdap.php
119 lines (94 loc) · 3.08 KB
/
ussdap.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
//Shehan Bhavan - hSenid Mobile Solutions
//shehanb@hsenidmobile.com
//Dialog Ideamart
ini_set('error_log', 'ussd-app-error.log');
require 'libs/MoUssdReceiver.php';
require 'libs/MtUssdSender.php';
require 'class/operationsClass.php';
require 'libs/Log.php';
require 'db.php';
$production=false;
if($production==false){
$ussdserverurl ='http://localhost:7000/ussd/send';
}
else{
$ussdserverurl= 'https://api.dialog.lk/ussd/send';
}
$receiver = new UssdReceiver();
$sender = new UssdSender($ussdserverurl,'APP_000001','password');
$operations = new Operations();
$content = $receiver->getMessage(); // get the message content
$address = $receiver->getAddress(); // get the sender's address
$requestId = $receiver->getRequestID(); // get the request ID
$applicationId = $receiver->getApplicationId(); // get application ID
$encoding = $receiver->getEncoding(); // get the encoding value
$version = $receiver->getVersion(); // get the version
$sessionId = $receiver->getSessionId(); // get the session ID;
$ussdOperation = $receiver->getUssdOperation(); // get the ussd operation
$responseMsg = array(
"main" =>
"Welcome To hSenid Mobile
1. Singapore
2. SriLanka
99. Exit"
);
if ($ussdOperation == "mo-init") {
try {
$sessionArrary=array("sessionsid"=>$sessionId,"tel"=>$address,"menu"=>"main","pg"=>"","others"=>"");
$operations->setSessions($sessionArrary);
$sender->ussd($sessionId, $responseMsg["main"],$address );
} catch (Exception $e) {
$sender->ussd($sessionId, 'Please try again',$address );
}
}else {
$flag=0;
$sessiondetails= $operations->getSession($sessionId);
$cuch_menu=$sessiondetails['menu'];
$operations->session_id=$sessiondetails['sessionsid'];
switch($cuch_menu){
case "main": // Following is the main menu
switch ($receiver->getMessage()) {
case "1":
$operations->session_menu="Singapore";
$operations->saveSesssion();
$sender->ussd($sessionId,'Enter Your ID',$address );
break;
case "2":
$operations->session_menu="SriLanka";
$operations->saveSesssion();
$sender->ussd($sessionId,'Enter Your ID',$address );
break;
default:
$operations->session_menu="main";
$operations->saveSesssion();
$sender->ussd($sessionId, $responseMsg["main"],$address );
break;
}
break;
case "Singapore":
$operations->session_menu="Srilanka";
$operations->session_others=$receiver->getMessage();
$operations->saveSesssion();
$sender->ussd($sessionId,'hSenid Mobile Solutions (Singapore)
7500A, Beach Road,
#05-322 The Plaza,
Singapore 199591.
+65 65 332 140
+65 62 910 023'.$receiver->getMessage(),$address ,'mt-fin');
break;
case "Srilanka":
$sender->ussd($sessionId,'hSenid Mobile Solutions
No 320, 3rd Floor,
T.B.Jayah Mawatha,
Colombo 10.
+94 11 268 6751
+94 11 268 3951'.$receiver->getMessage(),$address ,'mt-fin');
break;
default:
$operations->session_menu="main";
$operations->saveSesssion();
$sender->ussd($sessionId,'Incorrect option',$address );
break;
}
}