-
Notifications
You must be signed in to change notification settings - Fork 4
/
MobitelSMS.php
134 lines (109 loc) · 4.22 KB
/
MobitelSMS.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
namespace App\Library;
use \stdClass as stdClass;
use \SoapClient as SoapClient;
class MobitelSms {
/**
* Make client well Mobitel has made their backend with SoapClient we just want to include it on our class
* @return SoapClient
*/
public function bridge(){
ini_set("soap.wsdl_cache_enabled", "0");
$bridge = new SoapClient("http://smeapps.mobitel.lk:8585/EnterpriseSMS/EnterpriseSMSWS.wsdl");
return $bridge;
}
/**
* This will Make new session to Fire SMS
* @return SessionResponse from Mobitel
*/
public function sessionMake(){
//make bridge connection with mobitel before access Session
$bridge = $this->bridge();
//create customer with username & password provided by Mobitel
$customer = new stdClass();
$customer->id = ''; //ingore this Mobitel will take care of this
$customer->username = 'USERNAME';
$customer->password = 'PASSWORD';
$customer->customer = ''; //ingore this that;s Mobitel's stuff :P
//create session for you / your customer based on credintials
$makeSession = new stdClass();
$makeSession->arg0 = $customer;
//new object for session response from Mobitel
$makeSessionResponse = new stdClass();
//map session response with Soap aka Bridge
$makeSessionResponse = $bridge->createSession($makeSession);
//well what else you need you are ready to go ;)
return $makeSessionResponse->return;
}
public function fireSms($session, $text, $number){
$client = $this->bridge(); //get client
$aliasObj=new stdClass();
$aliasObj->alias="ALIAS";
$aliasObj->customer="";
$aliasObj->id="";
$smsMessage= new stdClass();
$smsMessage->message=$text;
$smsMessage->messageId="";
$smsMessage->recipients=$number;
$smsMessage->retries="";
$smsMessage->sender=$aliasObj;
$smsMessage->sequenceNum="";
$smsMessage->status="";
$smsMessage->time="";
$smsMessage->type="";
$smsMessage->user="";
$sendMessages=new stdClass();
$sendMessages->arg0=$session;
$sendMessages->arg1=$smsMessage;
$sendMessagesResponse=new stdClass();
$sendMessagesResponse=$client->sendMessages($sendMessages);
return $sendMessagesResponse->return;
}
public function sessionRenew($session){
$client = $this->bridge(); //get client
$renewSession=new stdClass();
$renewSession->arg0=$session;
$renewSessionResponse=new stdClass();
$renewSessionResponse=$client->renewSession($renewSession);
return $renewSessionResponse;
}
public function sessionClose($session){
$client = $this->bridge(); //get client
$closeSession=new stdClass();
$closeSession->arg0=$session;
$client->closeSession($closeSession);
}
public function sessionCheck($session){
$client = $this->bridge(); //get client
$isSession= new stdClass();
$isSession->arg0=$session;
$isSessionResponse=new stdClass();
$isSessionResponse= $client->isSession($isSession);
return $isSessionResponse;
}
public function statusCheck(){
$client = $this->bridge(); //get client
$user = new stdClass();
$user->id = '';
$user->username='USERNAME';
$user->password='PASSWORD';
$user->customer = '';
$serviceTest=new stdClass();
$serviceTest->arg0=$user;
return $client->serviceTest($serviceTest);
}
public function statusDelivery($session, $alias){
$client = $this->bridge(); //get client
$aliasObj=new stdClass();
$aliasObj->alias=$alias;
$getDeliveryReports=new stdClass();
$getDeliveryReports->arg0=$session;
$getDeliveryReports->arg1=$aliasObj;
$getDeliveryReportsResponse=new stdClass();
$getDeliveryReportsResponse->return="";
$getDeliveryReportsResponse=$client->getDeliveryReports($getDeliveryReports);
if(property_exists($getDeliveryReportsResponse,'return'))
return $getDeliveryReportsResponse->return;
else return NULL;
}
}