[443] | 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 | {
|
---|
[457] | 11 | private $_xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
|
---|
| 12 |
|
---|
[443] | 13 | public function __construct()
|
---|
| 14 | {
|
---|
| 15 | parent::__construct();
|
---|
| 16 | }
|
---|
| 17 |
|
---|
[499] | 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 |
|
---|
[457] | 27 | public function testmo() {
|
---|
[470] | 28 | $url = 'http://10.58.38.162/violetservice/soanbai/mo?wsdl';
|
---|
| 29 |
|
---|
[457] | 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 |
|
---|
[470] | 55 | echo $client->responseData;
|
---|
| 56 |
|
---|
| 57 | /* $err = $client->getError();
|
---|
[457] | 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>";
|
---|
[470] | 67 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; */
|
---|
[457] | 68 | }
|
---|
| 69 |
|
---|
[499] | 70 | public function send($msg, $receiverID)
|
---|
[443] | 71 | {
|
---|
| 72 | $url = $this->config->item('mt_service_url');
|
---|
| 73 | $username = 'sbg';
|
---|
| 74 | $password = 'sbg56ab77cdsgb';
|
---|
| 75 | $operator = 'InsertMT';
|
---|
| 76 | $operation = 'http://tempuri.org/InsertMT';
|
---|
[499] | 77 |
|
---|
| 78 | $aryMatch = array();
|
---|
| 79 | if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) {
|
---|
| 80 | $receiverID = '84'. $aryMatch[2];
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[443] | 83 | $aryParams = array(
|
---|
| 84 | 'User' => $username,
|
---|
| 85 | 'Pass' => $password,
|
---|
| 86 | 'CPCode' => '601',
|
---|
| 87 | 'UserID' => '841662860000',
|
---|
| 88 | 'RequestID' => '4',
|
---|
[499] | 89 | 'ReceiverID' => $receiverID,
|
---|
[443] | 90 | 'ServiceID' => '8062',
|
---|
| 91 | 'CommandCode' => 'SBG',
|
---|
| 92 | 'ContentType' => '0',
|
---|
[457] | 93 | 'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
|
---|
[443] | 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 |
|
---|
[457] | 102 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
[443] | 103 | $err = $client->getError();
|
---|
| 104 |
|
---|
| 105 | if ($err) {
|
---|
| 106 | echo '<p><b>Error: ' . $err . '</b></p>';
|
---|
| 107 | }
|
---|
| 108 |
|
---|
[499] | 109 | var_dump($result);
|
---|
| 110 |
|
---|
[443] | 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 |
|
---|
[457] | 117 | }
|
---|
| 118 |
|
---|
| 119 | public function topup ()
|
---|
| 120 | {
|
---|
[470] | 121 | $url = $this->config->item('topup_service_url');
|
---|
[499] | 122 | $operation = 'http://tempuri.org/ITopupService/TopUp';;
|
---|
[457] | 123 |
|
---|
| 124 | $username = 'sbg';
|
---|
| 125 | $password = 'sbg56ab77cdsgb';
|
---|
| 126 |
|
---|
| 127 | $aryParams = array(
|
---|
| 128 | 'EWalletID' => 0,
|
---|
| 129 | 'CardSerial' => '11111',
|
---|
| 130 | 'PinCard' => 'eeeeeeeee'
|
---|
| 131 | );
|
---|
| 132 |
|
---|
| 133 | $xml = $this->load->view('topup', $aryParams, true);
|
---|
| 134 | $client = new nusoap_client($url);
|
---|
| 135 | $client->useHTTPPersistentConnection();
|
---|
| 136 | $client->soap_defencoding = 'UTF-8';
|
---|
| 137 | $client->operation = $operation;
|
---|
| 138 |
|
---|
| 139 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
| 140 | $err = $client->getError();
|
---|
| 141 |
|
---|
[470] | 142 | if ($client->fault) {
|
---|
| 143 | echo "<h2>Fault loi:</h2><pre>";
|
---|
| 144 | print_r($result);
|
---|
| 145 | echo "</pre>";
|
---|
[457] | 146 | }
|
---|
[470] | 147 | else {
|
---|
| 148 | $error = $client->getError();
|
---|
| 149 | if ($error) {
|
---|
| 150 | echo "<h2>Error</h2><pre>" . $error . "</pre>";
|
---|
| 151 | }
|
---|
| 152 | else {
|
---|
| 153 | echo "<h2>Ket Qua</h2><pre>";
|
---|
| 154 | var_dump($result);
|
---|
| 155 | echo "</pre>";
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
[457] | 158 | echo "<br/>";
|
---|
| 159 | echo "<h2>Request</h2>";
|
---|
| 160 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
| 161 | echo "<h2>Response</h2>";
|
---|
[470] | 162 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
|
---|
| 163 |
|
---|
[457] | 164 | }
|
---|
| 165 |
|
---|
| 166 | public function charging ()
|
---|
| 167 | {
|
---|
| 168 | $url = $this->config->item('charging_service_url');
|
---|
| 169 |
|
---|
| 170 | $username = $this->config->item('charging_username');
|
---|
| 171 | $password = $this->config->item('charging_password');
|
---|
| 172 |
|
---|
| 173 | $operator = 'processCharging';
|
---|
| 174 | $operation = 'http://tempuri.org/processCharging';
|
---|
| 175 |
|
---|
| 176 | $aryParams = array(
|
---|
| 177 | 'user' => $username,
|
---|
| 178 | 'pass' => $password,
|
---|
[499] | 179 | 'MSISDN' => '01662860000',
|
---|
[457] | 180 | 'Charging' => '100',
|
---|
| 181 | 'Contents' => 'Namta-Active'
|
---|
| 182 | );
|
---|
| 183 |
|
---|
| 184 | $xml = $this->load->view('charging', $aryParams, true);
|
---|
| 185 | $client = new nusoap_client($url);
|
---|
| 186 | $client->useHTTPPersistentConnection();
|
---|
| 187 | $client->soap_defencoding = 'UTF-8';
|
---|
| 188 | $client->operation = $operation;
|
---|
| 189 |
|
---|
| 190 | $result = $client->send($this->_xmlHeader.$xml, $operation);
|
---|
| 191 | $err = $client->getError();
|
---|
| 192 |
|
---|
| 193 | if ($err) {
|
---|
| 194 | echo '<p><b>Error: ' . $err . '</b></p>';
|
---|
| 195 | }
|
---|
| 196 |
|
---|
[499] | 197 | var_dump($result);
|
---|
| 198 |
|
---|
[457] | 199 | echo "<br/>";
|
---|
| 200 | echo "<h2>Request</h2>";
|
---|
| 201 | echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
|
---|
| 202 | echo "<h2>Response</h2>";
|
---|
| 203 | echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
|
---|
| 204 | }
|
---|
[443] | 205 | } |
---|