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

Last change on this file since 519 was 519, checked in by namnd, 11 years ago
File size: 5.9 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * Viettel Class
4 *
5 * @author dzungnv02
6 *
7 */
8
9class 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        }
25       
26        public function testmo() {
27                $url = 'http://10.58.38.162/violetservice/soanbai/mo?wsdl';
28
29                $aryParams = array(
30                                'username' => 'sbg',
31                                'password' => 'sbg571285',
32                                'requestID' => '4',
33                                'userID' => '841662860000',
34                                'receiverID' => '84988568786',
35                                'serviceID' => '8062',
36                                'commandCode' => 'SBG',
37                                'contentType' => '0',
38                                'info' => 'SBG DK',
39                                'receiveTime' => date('Ymd H:i:s')
40                );
41               
42                $client = new nusoap_client($url, false);
43                $client->useHTTPPersistentConnection();
44                $xml = $this->load->view('mo', null, true);
45               
46                $operator = 'MOReceiver';
47                $operation = 'http://tempuri.org/MOReceiver';
48
49                $client->soap_defencoding = 'UTF-8';
50                $client->operation = $operation;
51                $result = $client->send($this->_xmlHeader.$xml, $operation);           
52                //$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
53               
54                echo $client->responseData;
55               
56                /* $err = $client->getError();
57                       
58                if ($err) {
59                        echo '<p><b>Error: ' . $err . '</b></p>';
60                }
61               
62                echo "<br/>";
63                echo "<h2>Request</h2>";
64                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
65                echo "<h2>Response</h2>";
66                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; */           
67        }
68       
69        public function send($msg, $receiverID)
70        {
71                $url = $this->config->item('mt_service_url');
72                $username = 'sbg';
73                $password = 'sbg56ab77cdsgb';
74                $operator = 'InsertMT';
75                $operation = 'http://tempuri.org/InsertMT';
76               
77                $aryMatch = array();
78                if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) {
79                        $receiverID = '84'. $aryMatch[2];
80                }
81               
82                $aryParams = array(
83                                'User' => $username,
84                                'Pass' => $password,
85                                'CPCode' => '601',
86                                'UserID' => '841662860000',
87                                'RequestID' => '4',
88                                'ReceiverID' => $receiverID,
89                                'ServiceID' => '8062',
90                                'CommandCode' => 'SBG',
91                                'ContentType' => '0',
92                                'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
93                );
94       
95                $xml = $this->load->view('mt', $aryParams, true);
96                $client = new nusoap_client($url);
97                $client->useHTTPPersistentConnection();
98                $client->soap_defencoding = 'UTF-8';
99                $client->operation = $operation;
100       
101                $result = $client->send($this->_xmlHeader.$xml, $operation);
102                $err = $client->getError();
103                       
104                if ($err) {
105                        echo '<p><b>Error: ' . $err . '</b></p>';
106                }
107               
108                var_dump($result);
109               
110                echo "<br/>";
111                echo "<h2>Request</h2>";
112                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
113                echo "<h2>Response</h2>";
114                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
115       
116        }
117       
118        public function topup ()
119        {
120                $usID = $this->uri->segment(4);
121                $url = $this->config->item('topup_service_url');
122               
123                //echo file_get_contents($url);
124                //exit();
125               
126                $operation = 'http://tempuri.org/ITopupService/TopUp';
127               
128                $username = 'sbg';
129                $password = 'sbg56ab77cdsgb';
130               
131                $input = $this->input->post();
132                $cardSerial = $input['card_serial'];
133                $pinCard = $input['pin_card'];
134               
135                $aryParams = array(
136                        'EWalletID' => 0,
137                        'CardSerial' => $cardSerial,
138                        'PinCard' => $pinCard,
139                        'UserID' => $usID
140                );
141               
142                $this->load->model('services_model');
143                echo json_encode($this->services_model->cardPaidProcess($aryParams));
144
145                $xml = $this->load->view('topup', $aryParams, true);
146                $client = new nusoap_client($url);
147                $client->useHTTPPersistentConnection();
148                $client->soap_defencoding = 'UTF-8';
149                $client->operation = $operation;
150               
151                $result = $client->send($this->_xmlHeader.$xml, $operation);
152                $err = $client->getError();
153               
154                if ($client->fault) {
155                    echo "<h2>Fault loi:</h2><pre>";
156                    print_r($result);
157                    echo "</pre>";
158                }
159                else {
160                    $error = $client->getError();
161                    if ($error) {
162                        echo "<h2>Error</h2><pre>" . $error . "</pre>";
163                    }
164                    else {
165                        echo "<h2>Ket Qua</h2><pre>";
166                        var_dump($result);
167                        echo "</pre>";
168                    }
169                }
170                echo "<br/>";
171                echo "<h2>Request</h2>";
172                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
173                echo "<h2>Response</h2>";
174                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
175               
176        }
177       
178        public function charging ()
179        {
180                $url = $this->config->item('charging_service_url');
181               
182                $username = $this->config->item('charging_username');
183                $password = $this->config->item('charging_password');
184               
185                $operator = 'processCharging';
186                $operation = 'http://tempuri.org/processCharging';
187               
188                $aryParams = array(
189                                'user' => $username,
190                                'pass' => $password,
191                                'MSISDN' => '01662860000',
192                                'Charging' => '100',
193                                'Contents' => 'Namta-Active'
194                );
195               
196                $xml = $this->load->view('charging', $aryParams, true);
197                $client = new nusoap_client($url);
198                $client->useHTTPPersistentConnection();
199                $client->soap_defencoding = 'UTF-8';
200                $client->operation = $operation;
201               
202                $result = $client->send($this->_xmlHeader.$xml, $operation);
203                $err = $client->getError();
204                       
205                if ($err) {
206                        echo '<p><b>Error: ' . $err . '</b></p>';
207                }
208               
209                var_dump($result);
210               
211                echo "<br/>";
212                echo "<h2>Request</h2>";
213                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
214                echo "<h2>Response</h2>";
215                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";             
216        }
217}
Note: See TracBrowser for help on using the repository browser.