public function sendsmsAction() { $model = new WsServiceImport(); $messageModel = new WsServiceImportMessage(); $importToSend = $model->getImportToSend(); $servicesModel = new WsServiceSms(); $cfg = Zend_Registry::get('config'); while ($current = $importToSend->current()) { $services = Zend_Json::decode($current->services); $service = $servicesModel->getService($services[0]); $config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $service->service_hash); $http = new Zend_Controller_Request_Http(); $host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/'; $config['wsdl'] = $host . 'sms/?wsdl'; $sms = new SmsSoapClient($config); if (!$model->checkStatus($current->id)) { $importToSend->next(); $current = $importToSend->current(); } if ($importToSend->valid()) { switch ($current->file_type) { case 1: $sms->registerNumber($current->phone_number)->registerContent($current->sms_text); $response = $sms->send(); break; case 2: $tags = Zend_Json::decode($current->tags); $msg = $current->sms_text; if (!empty($tags)) { foreach ($tags as $key => $tag) { $msg = preg_replace("/<" . $key . ">/", $tag, $msg); } } $sms->registerNumber($current->phone_number)->registerContent($msg); $response = $sms->send(); break; case 3: $sms->registerNumber($current->phone_number)->registerContent($current->sms_text); $response = $sms->send(); break; } if (isset($response->errorCode)) { $messageModel->changeStatus($current->msg_id, $response->errorCode, Zend_Json::encode($response->smsId)); } else { $messageModel->changeStatus($current->msg_id, $response->faultcode, NULL, $response->faultstring); } $importToSend->next(); } } }
/** * @return void */ public function indexAction() { $form = new Logic_Ws_Sms_Tester_Form_Generic(); $response = null; if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $values = $form->getValues(); $cfg = Zend_Registry::get('config'); $config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $values['sms_account']); $http = new Zend_Controller_Request_Http(); $host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/'; switch ($values['env_type']) { case '1': $config['wsdl'] = $host . 'sms/?wsdl'; break; default: $config['wsdl'] = $host . 'sms/?wsdl'; } $sms = new SmsSoapClient($config); if ($values['confidental_type'] == 'on') { $sms->setConfidental(true); } try { switch ($values['sms_mode']) { case 'info': $sms->registerSmsID($values['sms_id']); $response = $this->_dump($sms->getSmsInfo()); break; case 'infomany': $sms->registerSmsIDManyRaw($values['sms_ids']); $response = $this->_dump($sms->getSmsInfoMany()); break; case 'package': $sms->registerContent($values['sms_content'])->setPackageRecipients($this->_explode($values['package_recipients'])); $response = $this->_dump($sms->send()); break; case 'packageinfo': $sms->registerPackageID($values['package_id']); $response = $this->_dump($sms->getPackageInfo()); break; case 'template': $sms->registerNumber($values['recipient_number'])->registerTemplate($values['template_name'], $values['sms_content'], $this->_explode($values['template_params']), $this->_explode($values['template_params_conf'])); switch ($values['template_mode']) { case '1': $sms->setTemplateNew(true); break; case '2': $sms->setTemplateForceUpdate(true); break; default: } $response = $this->_dump($sms->send()); break; case 'text': $sms->registerNumber($values['recipient_number'])->registerContent($values['sms_content']); $response = $this->_dump($sms->send()); break; default: // do nothing. } } catch (Exception $e) { $response = $this->_dump(array('Komunikat' => $e->getCode() . ':: ' . $e->getMessage())); } } } $this->view->form = $form; $this->view->response = $response; }
public function checkstatusAction() { $this->_helper->getHelper('ViewRenderer')->setNoRender(true); $request = $this->getRequest(); $id = $this->_helper->IdConvert->hexToStr($request->getParam('id')); if (empty($id)) { $this->_helper->messenger->error('Nie podano parametru ID'); return null; } try { $smsInfo = $this->_model->getSmsInfo($id); $cfg = Zend_Registry::get('config'); $config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $smsInfo->service_hash); $http = new Zend_Controller_Request_Http(); $host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/'; switch ($values['env_type']) { case '1': $config['wsdl'] = $host . 'sms/?wsdl'; break; default: $config['wsdl'] = $host . 'sms/?wsdl'; } $sms = new SmsSoapClient($config); $sms->registerSmsIDManyRaw($smsInfo->smsid); $response = $sms->getSmsInfoMany(); foreach ($response as $r) { if ($r->errorCode == 0) { $message .= "SMS o ID:" . $r->smsId . " został wysłany"; } else { $message .= "SMS o ID: " . $r->smsId . " nie został wysłany: " . $r->errorMessage . '(' . $r->errorCode . ')'; } } $this->_helper->messenger->info($message); $this->_redirect($this->getRequest()->getHeader('referer')); return; } catch (Exception $ex) { $this->_helper->messenger->error(); $this->_redirect($this->getRequest()->getHeader('referer')); } }