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 | // get total page
|
---|
222 | $totalpage = 1;
|
---|
223 | $default = $this->Services_model->getCollaborator(2,1,1);
|
---|
224 | if($default){
|
---|
225 | $xml = simplexml_load_string($default);
|
---|
226 | $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/");
|
---|
227 | $xml = $xml->xpath('//S:Body')[0];
|
---|
228 | $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/");
|
---|
229 | $totalpage = (int)$xml->xpath('//return//totalpage')[0];
|
---|
230 | }
|
---|
231 |
|
---|
232 | $result = $this->Services_model->getCollaborator(2,1,$totalpage);
|
---|
233 | if ($result){
|
---|
234 | $xml = simplexml_load_string($result);
|
---|
235 | $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/");
|
---|
236 | $xml = $xml->xpath('//S:Body')[0];
|
---|
237 | $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/");
|
---|
238 | $lst = $xml->xpath('//return//lst');
|
---|
239 | foreach($lst as $item){
|
---|
240 | $item = (array)$item;
|
---|
241 | if ((string)$item['phone']){
|
---|
242 | $data = array(
|
---|
243 | 'address'=> (string)$item['address'],
|
---|
244 | 'code'=>(string)$item['code'],
|
---|
245 | 'district'=>(string)$item['district'],
|
---|
246 | 'email'=>(string)$item['email'],
|
---|
247 | 'id'=>(int)$item['id'],
|
---|
248 | 'full_name'=>(string)$item['name'],
|
---|
249 | 'cellphone'=>(string)$item['phone'],
|
---|
250 | 'precinct'=>(string)$item['precinct'],
|
---|
251 | 'province'=>(string)$item['province'],
|
---|
252 | 'updated_time'=>date('Y-m-d H:i:s')
|
---|
253 | );
|
---|
254 | $this->Services_model->syncCollaborator($data);
|
---|
255 | }
|
---|
256 | }
|
---|
257 | }else{
|
---|
258 | $logMsg = date('Y-m-d H:i:s') . " Result is null \n";
|
---|
259 | write_file('./log/sync_collaborator.log', $logMsg, FOPEN_WRITE_CREATE);
|
---|
260 | }
|
---|
261 | }
|
---|
262 | } |
---|