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 chargingws ()
|
---|
175 | {
|
---|
176 | //$op = $this->input->get('op', TRUE);
|
---|
177 | //$op = trim($op) == '' ? 'Balance' : 'processCharging';
|
---|
178 | $url = $this->config->item('charging_service_url');
|
---|
179 | $content = file_get_contents ($url.'?op=Charge');
|
---|
180 | header('Content-Type: text/html; charset=utf-8');
|
---|
181 | echo $content;
|
---|
182 | }
|
---|
183 |
|
---|
184 | public function getBalance()
|
---|
185 | {
|
---|
186 | //GetAmountBalance
|
---|
187 | $url = $this->config->item('charging_service_url');
|
---|
188 |
|
---|
189 | $username = $this->config->item('charging_username');
|
---|
190 | $password = $this->config->item('charging_password');
|
---|
191 | $operator = 'GetAmountBalance';
|
---|
192 | $operation = 'http://tempuri.org/Balance';
|
---|
193 |
|
---|
194 | $aryParams = array(
|
---|
195 | 'user' => $username,
|
---|
196 | 'pass' => $password,
|
---|
197 | 'MSISDN' => '01662860000',
|
---|
198 | );
|
---|
199 |
|
---|
200 | $xml = $this->load->view('chargingBalance', $aryParams, true);
|
---|
201 | $client = new nusoap_client($url.'?op=Balance');
|
---|
202 | $client->useHTTPPersistentConnection();
|
---|
203 | $client->soap_defencoding = 'UTF-8';
|
---|
204 | $client->operation = $operation;
|
---|
205 |
|
---|
206 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
207 | $err = $client->getError();
|
---|
208 |
|
---|
209 | if ($err) {
|
---|
210 | echo '<p><b>Error: ' . $err . '</b></p>';
|
---|
211 | }
|
---|
212 |
|
---|
213 | var_dump($result);
|
---|
214 |
|
---|
215 | echo "<br/>";
|
---|
216 | echo "<h2>Request</h2>";
|
---|
217 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
218 | echo "<h2>Response</h2>";
|
---|
219 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
|
---|
220 | }
|
---|
221 |
|
---|
222 | public function charging ()
|
---|
223 | {
|
---|
224 | $url = $this->config->item('charging_service_url');
|
---|
225 |
|
---|
226 | $username = $this->config->item('charging_username');
|
---|
227 | $password = $this->config->item('charging_password');
|
---|
228 |
|
---|
229 | $operator = 'processCharging';
|
---|
230 | $operation = 'http://tempuri.org/Charge';
|
---|
231 |
|
---|
232 | $aryParams = array(
|
---|
233 | 'user' => $username,
|
---|
234 | 'pass' => $password,
|
---|
235 | 'MSISDN' => '01662860000',
|
---|
236 | 'Charging' => '100',
|
---|
237 | 'Contents' => 'Namta-Active'
|
---|
238 | );
|
---|
239 |
|
---|
240 | $xml = $this->load->view('charging', $aryParams, true);
|
---|
241 | $client = new nusoap_client($url);
|
---|
242 | $client->useHTTPPersistentConnection();
|
---|
243 | $client->soap_defencoding = 'UTF-8';
|
---|
244 | $client->operation = $operation;
|
---|
245 |
|
---|
246 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
247 | $err = $client->getError();
|
---|
248 |
|
---|
249 | if ($err) {
|
---|
250 | echo '<p><b>Error: ' . $err . '</b></p>';
|
---|
251 | }
|
---|
252 |
|
---|
253 | var_dump($result);
|
---|
254 |
|
---|
255 | echo "<br/>";
|
---|
256 | echo "<h2>Request</h2>";
|
---|
257 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
258 | echo "<h2>Response</h2>";
|
---|
259 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
|
---|
260 | }
|
---|
261 |
|
---|
262 | public function getCollaborators () {
|
---|
263 | $client = new SoapClient($this->config->item('bccs_service_url'), array( 'trace' => true,
|
---|
264 | 'exceptions' => true,
|
---|
265 | ));
|
---|
266 | $username = $this->config->item('bccs_username');
|
---|
267 | $password = $this->config->item('bccs_password');
|
---|
268 | $wscode = 'getListShopAndStaftInfo';
|
---|
269 |
|
---|
270 | $input = new Input($username, $password, $wscode/* , 2, 1,5000 */);
|
---|
271 | $param = new Param();
|
---|
272 |
|
---|
273 | $params = array(
|
---|
274 | "Input" => $input,
|
---|
275 | "rawData" => "rawData",
|
---|
276 | "Param" => $param,
|
---|
277 | );
|
---|
278 |
|
---|
279 | var_dump($params);
|
---|
280 |
|
---|
281 | $response = $client->__soapCall("gwOperation", array($params));
|
---|
282 | var_dump($response);
|
---|
283 | }
|
---|
284 |
|
---|
285 |
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 | class Input {
|
---|
290 | function Input ($user, $pass, $wscode/*, $type, $page, $displaypage */) {
|
---|
291 | $this->user = $user;
|
---|
292 | $this->pass = $pass;
|
---|
293 | $this->wscode = $wscode;
|
---|
294 | $this->param = null;
|
---|
295 | $this->rawData = '';
|
---|
296 | /* $this->type = $type;
|
---|
297 | $this->page = $page;
|
---|
298 | $this->displaypage = $displaypage; */
|
---|
299 | }
|
---|
300 | }
|
---|
301 |
|
---|
302 | class Param {
|
---|
303 | function Param () {
|
---|
304 | $this->name = '';
|
---|
305 | $this->value = '';
|
---|
306 | }
|
---|
307 | }
|
---|
308 | function fix_latin1_mangled_with_utf8_maybe_hopefully_most_of_the_time($str)
|
---|
309 | {
|
---|
310 | return preg_replace_callback('#[\\xA1-\\xFF](?![\\x80-\\xBF]{2,})#', 'utf8_encode_callback', $str);
|
---|
311 | }
|
---|
312 |
|
---|
313 | function utf8_encode_callback($m)
|
---|
314 | {
|
---|
315 | return utf8_encode($m[0]);
|
---|
316 | } |
---|