Esempio n. 1
0
 /**
  * method to send
  * 
  * @param type $message
  * @param type $recipients
  * @return \Billrun_Sms|boolean
  */
 public function send($message, $recipients)
 {
     if (empty($message) || empty($recipients)) {
         Billrun_Factory::log()->log("can not send the sms, there are missing params - txt: " . $this->data['message'] . " recipients: " . print_r($this->data['recipients'], TRUE) . " from: " . $this->data['from'], Zend_Log::WARN);
         return false;
     }
     $unicode_text = $this->sms_unicode($message);
     if (!empty($message) && empty($unicode_text)) {
         $language = '1';
     } else {
         $language = '2';
     }
     // Temporary - make sure is not 23 chars long
     $text = str_pad($message, 24, '+');
     $period = 120;
     foreach ($recipients as $recipient) {
         $send_params = array('message' => $text, 'to' => $recipient, 'from' => $this->data['from'], 'language' => $language, 'username' => $this->data['user'], 'password' => $this->data['pwd'], 'acknowledge' => "false", 'period' => $period, 'channel' => "SRV");
         $url = $this->data['provisioning'] . "?" . http_build_query($send_params);
         $sms_result = Billrun_Util::sendRequest($url);
         $exploded = explode(',', $sms_result);
         $response = array('error-code' => empty($exploded[0]) ? 'error' : 'success', 'cause-code' => $exploded[1], 'error-description' => $exploded[2], 'tid' => $exploded[3]);
         Billrun_Factory::log()->log("phone: " . $recipient . " encoded_text: " . $message . " url: " . $url . " result" . print_R($response, 1), Zend_Log::INFO);
     }
     return $response['error-code'] == 'success' ? true : false;
 }
Esempio n. 2
0
 /**
  * Notify remote server on an event.
  * @param type $query_args the argument to pass in the url query
  * @param type $post_args extra data to pass as post data
  * 
  * @return mixed on success - the decoded values that was return  from the remote server (using json). on failure - false
  */
 protected function notifyRemoteServer($query_args, $post_args)
 {
     // TODO: use Zend_Http_Client instead
     // http://framework.zend.com/manual/1.12/en/zend.http.client.adapters.html#zend.http.client.adapters.curl
     $url = 'http://' . $this->alertServer . $this->alertPath . '?' . http_build_query($query_args);
     unset($post_args['stamps']);
     $post_array = array_diff($post_args, $query_args);
     $post_fields = array('extra_data' => Zend_Json::encode($post_array));
     Billrun_Log::getInstance()->log("fraudAlertsPlugin::notifyRemoteServer URL: " . $url, Zend_Log::INFO);
     if (!$this->isDryRun) {
         $output = Billrun_Util::sendRequest($url, $post_fields, Zend_Http_Client::POST);
         Billrun_Log::getInstance()->log("fraudAlertsPlugin::notifyRemoteServer response: " . $output, Zend_Log::INFO);
         $ret = json_decode($output, true);
         if (is_null($ret)) {
             Billrun_Log::getInstance()->log("fraudAlertsPlugin::notifyRemoteServer response is empty, null or not json string: ", Zend_Log::ERR);
             return FALSE;
         }
         Billrun_Log::getInstance()->log("fraudAlertsPlugin::notifyRemoteServer decode: " . print_r($ret, 1), Zend_Log::INFO);
         return $ret;
     } else {
         Billrun_Log::getInstance()->log("fraudAlertsPlugin::notifyRemoteServer - Running in DRY RUN mode returning successful alert.", Zend_Log::INFO);
         return array('deposit_result' => 1, 'transaction_status' => 00, 'phase' => NULL, 'subscriber_id' => 1337, 'NDC_SN' => $query_args['NDC_SN'], 'IMSI' => $query_args['IMSI'], 'SECOND_IMSI' => $query_args['IMSI'], 'account_id' => 1337, 'SMS' => 1, 'EMAIL' => 1, 'success' => 1);
     }
 }