示例#1
0
文件: InfoSms.php 项目: knatorski/SMS
 /**
  * @param integer $smsId
  * @throws Logic_WebService_Sms_Exception
  */
 public function handle($smsId)
 {
     if (empty($smsId)) {
         throw new Logic_WebService_Sms_Exception('Niepoprawny identyfikator sms: (nie podano wartosci)', 422);
     }
     $multiinfo = new Logic_Service_SerwerSMS($this->_service->getParams()->service_login, $this->_service->getParams()->service_password, $this->_service->getParams()->new_api);
     $handler = new Logic_Service_Multiinfo_Response(new Logic_Service_SerwerSMS_Response_InfoSms());
     return $handler->handle($multiinfo->infosms($smsId));
 }
示例#2
0
文件: GetSms.php 项目: knatorski/SMS
 /**
  * @return Logic_Service_Multiinfo_Response_GetSms
  */
 public function handle()
 {
     $multiinfo = new Logic_Service_SerwerSMS($this->_service->getParams()->service_login, $this->_service->getParams()->service_password, $this->_service->getParams()->new_api);
     $handler = new Logic_Service_Multiinfo_Response(new Logic_Service_SerwerSMS_Response_GetSms());
     return $handler->handle($multiinfo->getsms($this->_service->getParams()->phone_number));
 }
示例#3
0
 /**
  *
  * @param string $number            
  * @param mixed $content            
  * @param boolean $isContentConfidentially            
  * @param Logic_Service_Multiinfo_Params $params            
  * @throws Logic_WebService_Sms_Exception
  * @return Logic_Service_Multiinfo_Response_Container
  */
 public function handle($number = null, $content = null, $isContentConfidentially = false, Logic_Service_Multiinfo_Params $params = null)
 {
     $recipient = new Logic_WebService_Sms_Recipient($number);
     // jezeli to NIE jest produkcja sprawdzam, czy numer jest na liscie
     // numerow tel. bezpiecznych do wykonania testow
     if (!$this->_environment->checkStatus()) {
         $recipient->checkNumberOnWhiteList();
     }
     $content = new Logic_WebService_Sms_Content($content, $isContentConfidentially);
     // sprawdzam na liscie numerow zablokowanych do wysylki dla tej uslugi
     if ($recipient->checkNumberOnBlackList($this->_client->getParams()->id)) {
         $model = new SmsBlacklistStorage();
         $model->addSms($recipient->getRecipient()->id, $this->_client->getParams()->id, $this->_service->getParams()->id, $content->getHash(), $content->getContentToLog());
         throw new Logic_WebService_Sms_Exception('Proba wyslania sms na numer obecny na blacklist: ' . $this->_number, 417);
     }
     // test limitow ilosciowych miesiac/dzien
     $recipient->checkLimit($this->_client, $this->_service);
     // test numeru na limit ilosciowy sms z dana trescia
     $recipient->checkLimitByContent($this->_client, $this->_service, $content);
     // jesli wszystko jest ok, probuje wyslac sms
     if ($this->_service->getParams()->use_db) {
         throw new Exception("Functionality not implemented in this Service Type yet.");
         // $multiinfo = new
         // Logic_Service_Multiinfo_ToDb($this->_service->getParams()->service_login,
         // $this->_service->getParams()->service_password);
     } else {
         $multiinfo = new Logic_Service_SerwerSMS($this->_service->getParams()->service_login, $this->_service->getParams()->service_password);
     }
     $contentLenght = $content->countContentLenght();
     if ($contentLenght > 1377) {
         // maksymalny rozmiar sms long
         throw new Logic_WebService_Sms_Exception('Przekroczono limit maksymalnego rozmiaru sms (max. 1377; wiadomosc: ' . $contentLenght . ')', 423);
     } elseif ($contentLenght > 160) {
         // sms long
         throw new Logic_WebService_Sms_Exception('Obsługa wiadomości dłuższych niż 160 znaków nie została zaimplementowana w tej wersji.', 424);
         // $handler = new Logic_Service_Multiinfo_Response(new
         // Logic_Service_Multiinfo_Response_SendSmsLong());
         // $response = $handler->handle($multiinfo->sendsmslong(
         // $this->_service->getParams()->special_id,
         // $recipient->getNumber(), $content->getContent(),
         // $params->validTo,
         // $params->delivNotifRequest, $params->advancedEncoding,
         // $params->deleteContent
         // ));
     } elseif ($contentLenght > 0 && $contentLenght <= 160) {
         // sms standard
         $handler = new Logic_Service_Multiinfo_Response(new Logic_Service_SerwerSMS_Response_SendSms());
         $response = $handler->handle($multiinfo->sendsms($this->_service->getParams()->special_id, $recipient->getNumber(), $content->getContent(), $params->validTo, $params->delivNotifRequest, $params->zeroclass, $params->advancedEncoding, $params->deleteContent, $this->_service->getParams()->from_title));
     } else {
         // z jakiegos powodu wiadomosc jest pusta (nie podano tresci,
         // pusty szablon, ogolnie awaria)
         throw new Logic_WebService_Sms_Exception('Proba wyslania pustego sms (brak tresci przygotowanej do wysylki)', 510);
     }
     $model = new SmsStorageWithOperator();
     $model->addSms($recipient->getRecipient()->id, $this->_client->getParams()->id, $this->_service->getParams()->id, $content->getHash(), $content->getContentToLog(), $response, Logic_WebService_Sms_Handler::$OPERATOR_SERVER_SMS);
     $smsLog = new Logic_WebService_Sms_Log();
     if ($response->status == true) {
         // wysylanie sms zakonczylo sie
         // sukcesem
         $smsLog->log('Wyslano SMS', 5, $response->toArray());
     } else {
         // wysylanie sms zakonczylo sie bledem
         $smsLog->log('Blad bramki SMS', 3, $response->toArray());
         $this->_errorHandler($response->errorCode, $response->errorMessage, $this->_service->getParams()->id);
     }
     return $response;
 }