source: pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php @ 939

Last change on this file since 939 was 909, checked in by dungnv, 10 years ago
File size: 8.4 KB
RevLine 
[523]1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * Viettel Class
[909]4 *
[523]5 * @author dzungnv02
6 *
7 */
8
[909]9class Sendmessage extends MX_Controller
[523]10{
11        private $_xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
[909]12
13        public function __construct()
[523]14        {
15                parent::__construct();
16        }
[909]17
18        public function index ()
[523]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        }
[909]31
[523]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                );
[909]47
[523]48                $client = new nusoap_client($url, false);
49                $client->useHTTPPersistentConnection();
50                $xml = $this->load->view('mo', null, true);
[909]51
[523]52                $operator = 'MOReceiver';
53                $operation = 'http://tempuri.org/MOReceiver';
54
55                $client->soap_defencoding = 'UTF-8';
56                $client->operation = $operation;
[909]57                $result = $client->send($this->_xmlHeader.$xml, $operation);
[523]58                //$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
[909]59
[523]60                echo $client->responseData;
[909]61
[523]62                /* $err = $client->getError();
[909]63
[523]64                if ($err) {
65                        echo '<p><b>Error: ' . $err . '</b></p>';
66                }
[909]67
[523]68                echo "<br/>";
69                echo "<h2>Request</h2>";
70                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
71                echo "<h2>Response</h2>";
[909]72                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; */
[523]73        }
[909]74
[523]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';
[909]82
[523]83                $aryMatch = array();
84                if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) {
85                        $receiverID = '84'. $aryMatch[2];
86                }
[909]87
[523]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                );
[909]100
[523]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;
[909]106
[523]107                $result = $client->send($this->_xmlHeader.$xml, $operation);
108                $err = $client->getError();
[909]109
[523]110                if ($err) {
111                        echo '<p><b>Error: ' . $err . '</b></p>';
112                }
[909]113
[523]114                var_dump($result);
[909]115
[523]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>";
[909]121
[523]122        }
[909]123
124        public function topup ()
[523]125        {
126                $url = $this->config->item('topup_service_url');
[909]127
[523]128                //echo file_get_contents($url);
129                //exit();
[909]130
[523]131                $operation = 'http://tempuri.org/ITopupService/TopUp';
[909]132
[523]133                $username = 'sbg';
134                $password = 'sbg56ab77cdsgb';
[909]135
[523]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;
[909]146
[523]147                $result = $client->send($this->_xmlHeader.$xml, $operation);
148                $err = $client->getError();
[909]149
[523]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>";
[909]171
[523]172        }
[909]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
[523]222        public function charging ()
223        {
224                $url = $this->config->item('charging_service_url');
[909]225
[523]226                $username = $this->config->item('charging_username');
227                $password = $this->config->item('charging_password');
[909]228
[523]229                $operator = 'processCharging';
[909]230                $operation = 'http://tempuri.org/Charge';
231
[523]232                $aryParams = array(
233                                'user' => $username,
234                                'pass' => $password,
235                                'MSISDN' => '01662860000',
236                                'Charging' => '100',
237                                'Contents' => 'Namta-Active'
238                );
[909]239
[523]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;
[909]245
[523]246                $result = $client->send($this->_xmlHeader.$xml, $operation);
247                $err = $client->getError();
[909]248
[523]249                if ($err) {
250                        echo '<p><b>Error: ' . $err . '</b></p>';
251                }
[909]252
[523]253                var_dump($result);
[909]254
[523]255                echo "<br/>";
256                echo "<h2>Request</h2>";
257                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
258                echo "<h2>Response</h2>";
[909]259                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
[523]260        }
[909]261
[884]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';
[909]269
[884]270                $input = new Input($username, $password, $wscode/* , 2, 1,5000 */);
271                $param = new Param();
[909]272
[884]273                $params = array(
274                                "Input" => $input,
275                                "rawData" => "rawData",
276                                "Param" => $param,
277                );
[909]278
[884]279                var_dump($params);
280
281                $response = $client->__soapCall("gwOperation", array($params));
282                var_dump($response);
283        }
[909]284
285
[695]286}
287
[884]288
289class 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
302class Param {
303        function Param () {
304                $this->name = '';
305                $this->value = '';
306        }
307}
[695]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        }
Note: See TracBrowser for help on using the repository browser.