- Timestamp:
- Nov 10, 2014 11:56:43 PM (11 years ago)
- Location:
- pro-violet-viettel/sourcecode/application/modules/services
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
r443 r457 9 9 class Sendmessage extends MX_Controller 10 10 { 11 11 private $_xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; 12 12 13 public function __construct() 13 14 { … … 15 16 } 16 17 17 public function send() 18 public function testmo() { 19 $url = 'http://10.58.38.162/violetservice/soanbai/mo'; 20 //$url = 'http://viettel.violet.vn/violetservice/soanbai/mo'; 21 $aryParams = array( 22 'username' => 'sbg', 23 'password' => 'sbg571285', 24 'requestID' => '4', 25 'userID' => '841662860000', 26 'receiverID' => '84988568786', 27 'serviceID' => '8062', 28 'commandCode' => 'SBG', 29 'contentType' => '0', 30 'info' => 'SBG DK', 31 'receiveTime' => date('Ymd H:i:s') 32 ); 33 34 $client = new nusoap_client($url, false); 35 $client->useHTTPPersistentConnection(); 36 $xml = $this->load->view('mo', null, true); 37 38 $operator = 'MOReceiver'; 39 $operation = 'http://tempuri.org/MOReceiver'; 40 41 $client->soap_defencoding = 'UTF-8'; 42 $client->operation = $operation; 43 $result = $client->send($this->_xmlHeader.$xml, $operation); 44 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) 18 61 { 19 62 $url = $this->config->item('mt_service_url'); … … 22 65 $operator = 'InsertMT'; 23 66 $operation = 'http://tempuri.org/InsertMT'; 24 $xmlHeader = '<?xml version="1.0" encoding="utf-8" ?>'."\n"; 25 67 26 68 $aryParams = array( 27 69 'User' => $username, … … 34 76 'CommandCode' => 'SBG', 35 77 'ContentType' => '0', 36 'Info' => 'SMS test!- Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),78 'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'), 37 79 ); 38 80 … … 43 85 $client->operation = $operation; 44 86 45 $result = $client->send($ xmlHeader.$xml, $operation);87 $result = $client->send($this->_xmlHeader.$xml, $operation); 46 88 $err = $client->getError(); 47 89 … … 56 98 echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; 57 99 58 } 100 } 101 102 public function topup () 103 { 104 $url = $this->config->item('topup_service_url'); 105 $operator = 'TopupService'; 106 $operation = 'http://tempuri.org/ITopupService/TopUp'; 107 108 $username = 'sbg'; 109 $password = 'sbg56ab77cdsgb'; 110 111 $aryParams = array( 112 'EWalletID' => 0, 113 'CardSerial' => '11111', 114 'PinCard' => 'eeeeeeeee' 115 ); 116 117 $xml = $this->load->view('topup', $aryParams, true); 118 $client = new nusoap_client($url); 119 $client->useHTTPPersistentConnection(); 120 $client->soap_defencoding = 'UTF-8'; 121 $client->operation = $operation; 122 123 $result = $client->send($this->_xmlHeader.$xml, $operation); 124 $err = $client->getError(); 125 126 if ($err) { 127 echo '<p><b>Error: ' . $err . '</b></p>'; 128 } 129 130 echo "<br/>"; 131 echo "<h2>Request</h2>"; 132 echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>"; 133 echo "<h2>Response</h2>"; 134 echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; 135 } 136 137 public function charging () 138 { 139 $url = $this->config->item('charging_service_url'); 140 141 $username = $this->config->item('charging_username'); 142 $password = $this->config->item('charging_password'); 143 144 $operator = 'processCharging'; 145 $operation = 'http://tempuri.org/processCharging'; 146 147 $aryParams = array( 148 'user' => $username, 149 'pass' => $password, 150 'MSISDN' => '1689925260', 151 'Charging' => '100', 152 'Contents' => 'Namta-Active' 153 ); 154 155 $xml = $this->load->view('charging', $aryParams, true); 156 $client = new nusoap_client($url); 157 $client->useHTTPPersistentConnection(); 158 $client->soap_defencoding = 'UTF-8'; 159 $client->operation = $operation; 160 161 $result = $client->send($this->_xmlHeader.$xml, $operation); 162 $err = $client->getError(); 163 164 if ($err) { 165 echo '<p><b>Error: ' . $err . '</b></p>'; 166 } 167 168 echo "<br/>"; 169 echo "<h2>Request</h2>"; 170 echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>"; 171 echo "<h2>Response</h2>"; 172 echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; 173 } 59 174 } -
pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php
r313 r457 10 10 { 11 11 12 public function __construct() 13 { 14 parent::__construct(); 12 function __construct() { 13 parent::__construct (); 14 $this->nusoap_server = new soap_server (); 15 $this->nusoap_server->configureWSDL('messageReceiver', 'urn:messageReceiver'); 16 $this->nusoap_server->soap_defencoding = 'UTF-8'; 17 $this->nusoap_server->methodreturnisliteral=TRUE; 18 19 $this->nusoap_server->wsdl->addComplexType( 20 'messageReceiver', 21 'simpleType', 22 'struct', 23 '', 24 'SOAP-ENC:Array', 25 array( 26 'username'=>array('name'=>'username', 'type'=>'xsd:string'), 27 'password'=>array('name'=>'password', 'type'=>'xsd:string'), 28 'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'), 29 'userID'=>array('name'=>'userID', 'type'=>'xsd:string'), 30 'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'), 31 'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'), 32 'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'), 33 'info'=>array('name'=>'info', 'type'=>'xsd:string'), 34 'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string') 35 ) 36 ); 37 38 $this->nusoap_server->register ( 'MOReceiver', 39 array( 'username' => 'xsd:string', 40 'password' => 'xsd:string', 41 'requestID' => 'xsd:string', 42 'userID' => 'xsd:string', 43 'receiverID' => 'xsd:string', 44 'serviceID' => 'xsd:string', 45 'commandCode' => 'xsd:string', 46 'info' => 'xsd:string', 47 'receiveTime' => 'xsd:string') 48 , array ('return' => 'xsd:string'),false,false 49 ,'rpc' 50 ); 15 51 } 16 52 17 public function index() 18 { 19 $this->load->view ( 'main'); 53 function index() { 54 if($this->uri->segment(3) == "wsdl") { 55 $_SERVER['QUERY_STRING'] = "wsdl"; 56 } else { 57 $_SERVER['QUERY_STRING'] = ""; 58 } 59 $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA:''; 60 $this->nusoap_server->service($HTTP_RAW_POST_DATA); 20 61 } 21 62 22 63 public function mo() 23 64 { 24 $aryParams = array(); 25 $aryParamsName = array( 'username', 26 'password', 27 'requestID', 28 'userID', 29 'receiverID', 30 'serviceID', 31 'commandCode', 32 'info', 33 'receiveTime'); 34 35 foreach ($aryParams as $key => $value) { 36 $aryParams[$value] = $this->input->post($value,TRUE); 65 function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info,$receiveTime){ 66 $msgType = '0'; //text message 67 $errCode = '1'; //#1:error; 1:Success; 68 69 $CI =& get_instance(); 70 $mo_username = $CI->config->item('mo_username'); 71 $mo_password = $CI->config->item('mo_password'); 72 73 /* if (!isset($parameters['username'])) return '0|0|Username is required!'; 74 if (!isset($parameters['password'])) return '0|0|Password is required!'; 75 if ($parameters['username'] != $mo_username) return '0|0|Username is not corrected!'.var_export($parameters, true); 76 if ($parameters['password'] != $mo_password) return '0|0|Password is not corrected!'; 77 if (!isset($parameters['userID'])) return '0|0|UserID is required!'; 78 if (!isset($parameters['userID'])) return '0|0|UserID is required!'; 79 if (!isset($parameters['serviceID'])) return '0|0|serviceID is required!'; 80 if ($parameters['serviceID'] != '8062') return '0|0|serviceID is not corrected!'; */ 81 82 if (!$username) return '0|0|Username is required!'; 83 if (!$password) return '0|0|Password is required!'; 84 if ($username != $mo_username) return '0|0|Username is not corrected!'; 85 if ($password != $mo_password) return '0|0|Password is not corrected!'; 86 if (!$requestID) return '0|0|requestID is required!'; 87 if (!$userID) return '0|0|UserID is required!'; 88 if (!$serviceID) return '0|0|serviceID is required!'; 89 if ($serviceID != '8062') return '0|0|serviceID is not corrected!'; 90 91 $sentNumber = $userID; 92 $username = !$receiverID ? $sentNumber : $receiverID; 93 94 $CI->load->model('frontend/user_model', 'userModel'); 95 $password = $CI->userModel->create_random_password(); 96 $sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan SBGOnline. Hay dang nhap vao http://soanbaigiang.smas.vn/ voi ten truy nhap ".$username.", mat khau ".$password." de su dung."; 97 //$msg = $CI->userModel->register ($sentNumber, $receiverID, $serviceID, $commandCode, $info, $receiveTime, $status); 98 99 //return $status.'|'.$msgType.'|'.$msg; 100 101 //for dummy data 102 return '1|0|'.$sms; 37 103 } 38 104 39 $this->load->model('Sms_model', 'objSMS'); 40 41 $separator = '|'; 42 $errCode = 1; 43 $messageType = 0; 44 $message = $this->objSMS->getSMSByServiceId();; 45 46 header('Content-type:text/html'); 47 echo $errCode,$separator,$messageType,$separator,$message; 48 } 49 50 public function mt() 51 { 52 105 $this->nusoap_server->service(file_get_contents("php://input")); 53 106 } 54 107 } 55 108 56 109 /* End of file viettel.php */ 57 /* Location: ./application/modules/service/controllers/viettel.php */ 110 /* Location: ./application/modules/service/controllers/viettel.php */
Note: See TracChangeset
for help on using the changeset viewer.