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

Last change on this file since 460 was 460, checked in by dungnv, 11 years ago
File size: 4.8 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 testmo() {
19                $url = 'http://10.58.38.162/violetservice/soanbai/mo';
20                //$url = 'http://10.58.38.162/services/viettel';
21                //$url = 'http://viettel.violet.vn/violetservice/soanbai/mo';
22                $aryParams = array(
23                                'username' => 'sbg',
24                                'password' => 'sbg571285',
25                                'requestID' => '4',
26                                'userID' => '841662860000',
27                                'receiverID' => '84988568786',
28                                'serviceID' => '8062',
29                                'commandCode' => 'SBG',
30                                'contentType' => '0',
31                                'info' => 'SBG DK',
32                                'receiveTime' => date('Ymd H:i:s')
33                );
34               
35                $client = new nusoap_client($url, false);
36                $client->useHTTPPersistentConnection();
37                $xml = $this->load->view('mo', null, true);
38               
39                $operator = 'MOReceiver';
40                $operation = 'http://tempuri.org/MOReceiver';
41
42                $client->soap_defencoding = 'UTF-8';
43                $client->operation = $operation;
44                $result = $client->send($this->_xmlHeader.$xml, $operation);           
45                //$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
46               
47                $err = $client->getError();
48                       
49                if ($err) {
50                        echo '<p><b>Error: ' . $err . '</b></p>';
51                }
52               
53                echo "<br/>";
54                echo "<h2>Request</h2>";
55                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
56                echo "<h2>Response</h2>";
57                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";             
58        }
59       
60        public function send($msg)
61        {
62                $url = $this->config->item('mt_service_url');
63                $username = 'sbg';
64                $password = 'sbg56ab77cdsgb';
65                $operator = 'InsertMT';
66                $operation = 'http://tempuri.org/InsertMT';
67                       
68                $aryParams = array(
69                                'User' => $username,
70                                'Pass' => $password,
71                                'CPCode' => '601',
72                                'UserID' => '841662860000',
73                                'RequestID' => '4',
74                                'ReceiverID' => '84988568786',
75                                'ServiceID' => '8062',
76                                'CommandCode' => 'SBG',
77                                'ContentType' => '0',
78                                'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
79                );
80       
81                $xml = $this->load->view('mt', $aryParams, true);
82                $client = new nusoap_client($url);
83                $client->useHTTPPersistentConnection();
84                $client->soap_defencoding = 'UTF-8';
85                $client->operation = $operation;
86       
87                $result = $client->send($this->_xmlHeader.$xml, $operation);
88                $err = $client->getError();
89                       
90                if ($err) {
91                        echo '<p><b>Error: ' . $err . '</b></p>';
92                }
93       
94                echo "<br/>";
95                echo "<h2>Request</h2>";
96                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
97                echo "<h2>Response</h2>";
98                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
99       
100        }
101       
102        public function topup ()
103        {
104                $operator = 'TopupService';
105                $operation = 'http://tempuri.org/ITopupService/TopUp';
106               
107                $username = 'sbg';
108                $password = 'sbg56ab77cdsgb';
109               
110                $aryParams = array(
111                        'EWalletID' => 0,
112                        'CardSerial' => '11111',
113                        'PinCard' => 'eeeeeeeee'
114                );
115               
116                $xml = $this->load->view('topup', $aryParams, true);
117                $client = new nusoap_client($url);
118                $client->useHTTPPersistentConnection();
119                $client->soap_defencoding = 'UTF-8';
120                $client->operation = $operation;
121               
122                $result = $client->send($this->_xmlHeader.$xml, $operation);
123                $err = $client->getError();
124                       
125                if ($err) {
126                        echo '<p><b>Error: ' . $err . '</b></p>';
127                }
128               
129                echo "<br/>";
130                echo "<h2>Request</h2>";
131                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
132                echo "<h2>Response</h2>";
133                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";             
134        }
135       
136        public function charging ()
137        {
138                $url = $this->config->item('charging_service_url');
139               
140                $username = $this->config->item('charging_username');
141                $password = $this->config->item('charging_password');
142               
143                $operator = 'processCharging';
144                $operation = 'http://tempuri.org/processCharging';
145               
146                $aryParams = array(
147                                'user' => $username,
148                                'pass' => $password,
149                                'MSISDN' => '1689925260',
150                                'Charging' => '100',
151                                'Contents' => 'Namta-Active'
152                );
153               
154                $xml = $this->load->view('charging', $aryParams, true);
155                $client = new nusoap_client($url);
156                $client->useHTTPPersistentConnection();
157                $client->soap_defencoding = 'UTF-8';
158                $client->operation = $operation;
159               
160                $result = $client->send($this->_xmlHeader.$xml, $operation);
161                $err = $client->getError();
162                       
163                if ($err) {
164                        echo '<p><b>Error: ' . $err . '</b></p>';
165                }
166               
167                echo "<br/>";
168                echo "<h2>Request</h2>";
169                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
170                echo "<h2>Response</h2>";
171                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";             
172        }
173}
Note: See TracBrowser for help on using the repository browser.