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

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