1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
2 | /**
|
---|
3 | * Viettel Class
|
---|
4 | *
|
---|
5 | * @author dzungnv02
|
---|
6 | *
|
---|
7 | */
|
---|
8 |
|
---|
9 | class Sendmessage extends MX_Controller
|
---|
10 | {
|
---|
11 | private $_xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
|
---|
12 |
|
---|
13 | public function __construct()
|
---|
14 | {
|
---|
15 | parent::__construct();
|
---|
16 | }
|
---|
17 |
|
---|
18 | public function index ()
|
---|
19 | {
|
---|
20 | error_reporting(E_ALL);
|
---|
21 | $this->load->model('Services_model');
|
---|
22 | //$this->Services_model->cardPaidProcess($aryParams);
|
---|
23 | //echo $this->Services_model->processMORequest('01662860000', strtoupper('sbg DDT 0979947802 123456'));
|
---|
24 | $aryParams = array(
|
---|
25 | 'EWalletID' => 0,
|
---|
26 | 'CardSerial' => '122346',
|
---|
27 | 'PinCard' => '123456789',
|
---|
28 | );
|
---|
29 | echo $this->Services_model->cardPaidProcess($aryParams);
|
---|
30 | }
|
---|
31 |
|
---|
32 | public function testmo() {
|
---|
33 | $url = 'http://10.58.38.162/violetservice/soanbai/mo?wsdl';
|
---|
34 |
|
---|
35 | $aryParams = array(
|
---|
36 | 'username' => 'sbg',
|
---|
37 | 'password' => 'sbg571285',
|
---|
38 | 'requestID' => '4',
|
---|
39 | 'userID' => '841662860000',
|
---|
40 | 'receiverID' => '84988568786',
|
---|
41 | 'serviceID' => '8062',
|
---|
42 | 'commandCode' => 'SBG',
|
---|
43 | 'contentType' => '0',
|
---|
44 | 'info' => 'SBG DK',
|
---|
45 | 'receiveTime' => date('Ymd H:i:s')
|
---|
46 | );
|
---|
47 |
|
---|
48 | $client = new nusoap_client($url, false);
|
---|
49 | $client->useHTTPPersistentConnection();
|
---|
50 | $xml = $this->load->view('mo', null, true);
|
---|
51 |
|
---|
52 | $operator = 'MOReceiver';
|
---|
53 | $operation = 'http://tempuri.org/MOReceiver';
|
---|
54 |
|
---|
55 | $client->soap_defencoding = 'UTF-8';
|
---|
56 | $client->operation = $operation;
|
---|
57 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
58 | //$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
|
---|
59 |
|
---|
60 | echo $client->responseData;
|
---|
61 |
|
---|
62 | /* $err = $client->getError();
|
---|
63 |
|
---|
64 | if ($err) {
|
---|
65 | echo '<p><b>Error: ' . $err . '</b></p>';
|
---|
66 | }
|
---|
67 |
|
---|
68 | echo "<br/>";
|
---|
69 | echo "<h2>Request</h2>";
|
---|
70 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
71 | echo "<h2>Response</h2>";
|
---|
72 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; */
|
---|
73 | }
|
---|
74 |
|
---|
75 | public function send($msg, $receiverID)
|
---|
76 | {
|
---|
77 | $url = $this->config->item('mt_service_url');
|
---|
78 | $username = 'sbg';
|
---|
79 | $password = 'sbg56ab77cdsgb';
|
---|
80 | $operator = 'InsertMT';
|
---|
81 | $operation = 'http://tempuri.org/InsertMT';
|
---|
82 |
|
---|
83 | $aryMatch = array();
|
---|
84 | if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) {
|
---|
85 | $receiverID = '84'. $aryMatch[2];
|
---|
86 | }
|
---|
87 |
|
---|
88 | $aryParams = array(
|
---|
89 | 'User' => $username,
|
---|
90 | 'Pass' => $password,
|
---|
91 | 'CPCode' => '601',
|
---|
92 | 'UserID' => '841662860000',
|
---|
93 | 'RequestID' => '4',
|
---|
94 | 'ReceiverID' => $receiverID,
|
---|
95 | 'ServiceID' => '8062',
|
---|
96 | 'CommandCode' => 'SBG',
|
---|
97 | 'ContentType' => '0',
|
---|
98 | 'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
|
---|
99 | );
|
---|
100 |
|
---|
101 | $xml = $this->load->view('mt', $aryParams, true);
|
---|
102 | $client = new nusoap_client($url);
|
---|
103 | $client->useHTTPPersistentConnection();
|
---|
104 | $client->soap_defencoding = 'UTF-8';
|
---|
105 | $client->operation = $operation;
|
---|
106 |
|
---|
107 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
108 | $err = $client->getError();
|
---|
109 |
|
---|
110 | if ($err) {
|
---|
111 | echo '<p><b>Error: ' . $err . '</b></p>';
|
---|
112 | }
|
---|
113 |
|
---|
114 | var_dump($result);
|
---|
115 |
|
---|
116 | echo "<br/>";
|
---|
117 | echo "<h2>Request</h2>";
|
---|
118 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
119 | echo "<h2>Response</h2>";
|
---|
120 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
|
---|
121 |
|
---|
122 | }
|
---|
123 |
|
---|
124 | public function topup ()
|
---|
125 | {
|
---|
126 | $url = $this->config->item('topup_service_url');
|
---|
127 |
|
---|
128 | //echo file_get_contents($url);
|
---|
129 | //exit();
|
---|
130 |
|
---|
131 | $operation = 'http://tempuri.org/ITopupService/TopUp';
|
---|
132 |
|
---|
133 | $username = 'sbg';
|
---|
134 | $password = 'sbg56ab77cdsgb';
|
---|
135 |
|
---|
136 | $aryParams = array(
|
---|
137 | 'EWalletID' => 0,
|
---|
138 | 'CardSerial' => '1111',
|
---|
139 | 'PinCard' => '222',
|
---|
140 | );
|
---|
141 | $xml = $this->load->view('topup', $aryParams, true);
|
---|
142 | $client = new nusoap_client($url);
|
---|
143 | $client->useHTTPPersistentConnection();
|
---|
144 | $client->soap_defencoding = 'UTF-8';
|
---|
145 | $client->operation = $operation;
|
---|
146 |
|
---|
147 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
148 | $err = $client->getError();
|
---|
149 |
|
---|
150 | if ($client->fault) {
|
---|
151 | echo "<h2>Fault loi:</h2><pre>";
|
---|
152 | print_r($result);
|
---|
153 | echo "</pre>";
|
---|
154 | }
|
---|
155 | else {
|
---|
156 | $error = $client->getError();
|
---|
157 | if ($error) {
|
---|
158 | echo "<h2>Error</h2><pre>" . $error . "</pre>";
|
---|
159 | }
|
---|
160 | else {
|
---|
161 | echo "<h2>Ket Qua</h2><pre>";
|
---|
162 | var_dump($result);
|
---|
163 | echo "</pre>";
|
---|
164 | }
|
---|
165 | }
|
---|
166 | echo "<br/>";
|
---|
167 | echo "<h2>Request</h2>";
|
---|
168 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
169 | echo "<h2>Response</h2>";
|
---|
170 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
|
---|
171 |
|
---|
172 | }
|
---|
173 |
|
---|
174 | public function charging ()
|
---|
175 | {
|
---|
176 | $url = $this->config->item('charging_service_url');
|
---|
177 |
|
---|
178 | $username = $this->config->item('charging_username');
|
---|
179 | $password = $this->config->item('charging_password');
|
---|
180 |
|
---|
181 | $operator = 'processCharging';
|
---|
182 | $operation = 'http://tempuri.org/processCharging';
|
---|
183 |
|
---|
184 | $aryParams = array(
|
---|
185 | 'user' => $username,
|
---|
186 | 'pass' => $password,
|
---|
187 | 'MSISDN' => '01662860000',
|
---|
188 | 'Charging' => '100',
|
---|
189 | 'Contents' => 'Namta-Active'
|
---|
190 | );
|
---|
191 |
|
---|
192 | $xml = $this->load->view('charging', $aryParams, true);
|
---|
193 | $client = new nusoap_client($url);
|
---|
194 | $client->useHTTPPersistentConnection();
|
---|
195 | $client->soap_defencoding = 'UTF-8';
|
---|
196 | $client->operation = $operation;
|
---|
197 |
|
---|
198 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
199 | $err = $client->getError();
|
---|
200 |
|
---|
201 | if ($err) {
|
---|
202 | echo '<p><b>Error: ' . $err . '</b></p>';
|
---|
203 | }
|
---|
204 |
|
---|
205 | var_dump($result);
|
---|
206 |
|
---|
207 | echo "<br/>";
|
---|
208 | echo "<h2>Request</h2>";
|
---|
209 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
210 | echo "<h2>Response</h2>";
|
---|
211 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
|
---|
212 | }
|
---|
213 |
|
---|
214 | public function collaborator ()
|
---|
215 | {
|
---|
216 | error_reporting(E_ALL);
|
---|
217 | $this->load->model('Services_model');
|
---|
218 |
|
---|
219 | $totalpage = 10213;
|
---|
220 |
|
---|
221 | $result = $this->Services_model->getCollaborator(2,1,1);
|
---|
222 | if ($result){
|
---|
223 | //$this->xml->parse($result);
|
---|
224 | //$xml = $this->xml;
|
---|
225 | //var_dump($xml);
|
---|
226 | /*
|
---|
227 | $xml = '<?xml version="1.0" ?>
|
---|
228 | <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
---|
229 | <S:Body>
|
---|
230 | <ns2:getListShopAndStaftInfoResponse xmlns:ns2="http://process.wsim.viettel.com/">
|
---|
231 | <return>
|
---|
232 | <description>Thᅵnh cᅵng</description>
|
---|
233 | <responseCode>0</responseCode>
|
---|
234 | <lst>
|
---|
235 | <address>S? nhᅵ null ???ng Null Khu?i Thu?m Huy?n T?ng B?c K?n B?c K?n</address>
|
---|
236 | <code>1000004001_00001_CTVTMDT</code>
|
---|
237 | <district>001</district>
|
---|
238 | <email></email>
|
---|
239 | <id>20513478</id>
|
---|
240 | <name>V? Th? Luy?n</name>
|
---|
241 | <phone></phone>
|
---|
242 | <precinct>004</precinct>
|
---|
243 | <province>B281</province>
|
---|
244 | </lst>
|
---|
245 | <lst>
|
---|
246 | <address>S? nhᅵ 01 ???ng 01 ??c Xuᅵn B?c K?n B?c K?n</address>
|
---|
247 | <code>1000004001_00002_GPKHDN</code>
|
---|
248 | <district>001</district>
|
---|
249 | <email></email>
|
---|
250 | <id>20536705</id>
|
---|
251 | <name>Chu ?ᅵnh Anh</name>
|
---|
252 | <phone>962143096</phone>
|
---|
253 | <precinct>004</precinct>
|
---|
254 | <province>B281</province>
|
---|
255 | </lst>
|
---|
256 | <lst>
|
---|
257 | <address>S? nhᅵ 186 ???ng Nguy?n Th? Minh Khai T? 8 Nguy?n Th? Minh Khai B?c K?n B?c K?n</address>
|
---|
258 | <code>1000004001_00003_CTVTMDT</code>
|
---|
259 | <district>001</district>
|
---|
260 | <email></email>
|
---|
261 | <id>20519414</id>
|
---|
262 | <name>Hoᅵng Cᅵng Minh</name>
|
---|
263 | <phone>0983532981</phone>
|
---|
264 | <precinct>004</precinct>
|
---|
265 | <province>B281</province>
|
---|
266 | </lst>
|
---|
267 | <page>1</page>
|
---|
268 | <totalpage>102123</totalpage>
|
---|
269 | </return>
|
---|
270 | </ns2:getListShopAndStaftInfoResponse>
|
---|
271 | </S:Body>
|
---|
272 | </S:Envelope>';
|
---|
273 | */
|
---|
274 | $xml = $result['result']['original'];
|
---|
275 | $xml = simplexml_load_string($xml);
|
---|
276 | $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/");
|
---|
277 | $xml = $xml->xpath('//S:Body')[0];
|
---|
278 | $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/");
|
---|
279 | $lst = $xml->xpath('//return//lst');
|
---|
280 | foreach($lst as $item){
|
---|
281 | $item = (array)$item;
|
---|
282 | $data = array(
|
---|
283 | 'address'=> (string)$item['address'],
|
---|
284 | 'code'=>(string)$item['code'],
|
---|
285 | 'district'=>(string)$item['district'],
|
---|
286 | 'email'=>(string)$item['email'],
|
---|
287 | 'id'=>(int)$item['id'],
|
---|
288 | 'full_name'=>(string)$item['name'],
|
---|
289 | 'cellphone'=>(string)$item['phone'],
|
---|
290 | 'precinct'=>(string)$item['precinct'],
|
---|
291 | 'province'=>(string)$item['province'],
|
---|
292 | 'updated_time'=>date('Y-m-d H:i:s')
|
---|
293 | );
|
---|
294 | $this->Services_model->syncCollaborator($data);
|
---|
295 | }
|
---|
296 | $totalpage = (int)$xml->xpath('//return//totalpage')[0];
|
---|
297 | //var_dump($totalpage);
|
---|
298 | }else{
|
---|
299 | var_dump($result);
|
---|
300 | }
|
---|
301 | }
|
---|
302 | } |
---|