예제 #1
0
 /**
  * Perform HTTP request
  *
  * @param   string  $method       HTTP method
  * @param   string  $url          Full URL including protocol
  * @param   array   $params       Any params
  * @return  mixed                 API response
  */
 protected function doRequest($method, $url, $params, $headers)
 {
     $request = $this->transport->createRequest();
     $request->setMethod($method);
     $request->fromUrl($url);
     $request->addHeaders($headers);
     $request->setContent($params);
     if ($this->isAuthenticated() && null !== $this->authenticator) {
         $request = $this->authenticator->authenticate($request);
     }
     return $this->transport->send($request);
 }
예제 #2
0
 /**
     С помощью массива $params, помимо текста сообщения, можно передать следующие параметры:
     action — принимает значения 'send' (отправить СМС, выбрано по-умолчанию) или 'check' (только проверить возможность отправки);
     datetime — дата и время отправки смс в формате (ГГГГ-ММ-ДД ЧЧ:ММ:СС);
     source — имя отправителя;
     onlydelivery (по-умолчанию 0 — платить за все смски, можно задать 1 — платить только за доставленные);
     regionalTime (по-умолчанию 0 — отправлять по вашему местному времени, можно задать 1 — отправлять по местному времени абонента);
     stop (по-умолчанию 1 — не отправлять абонентам, находящимся в Стоп-листах);
     smsid — желаемый id смски;
     use_alfasource (1 - отправлять через дорогой канал с согласованным именем отправителя. 0 - дешёвый канал.).
     allowed_opsos - перечисление операторов сотовой связи, которым можно отправлять это сообщение, через запятую, без пробелов.
     Например: "megafon,beeline". Остальным операторам сообщение отправляться не будет.
     exclude_opsos - перечисление операторов сотовой связи, которым запрещено отправлять это сообщение, через запятую, без пробелов.
     Например: "megafon,beeline". Остальным операторам сообщение будет отправлено.
 */
 public function sendsms()
 {
     if ($this->phone == null || $this->text == null) {
         return false;
         exit;
     }
     require_once __DIR__ . '/SmsService/transport.php';
     $api = new Transport();
     /*
     $params = array(
         "text" => $text
     );
     */
     //$send = $api->send($params,$phones);
     $send = $api->send(array('text' => $this->text), $this->phone);
     return $send;
 }
예제 #3
0
 /**
  * Send request to Moneybird
  * 
  * @access protected
  * @return string
  * @param string $url
  * @param string $method (GET|POST|PUT|DELETE)
  * @param string $data
  */
 protected function request($url, $method, $data = null)
 {
     $this->testLogin();
     try {
         $response = $this->transport->send($url, $method, $data, array('Content-Type: ' . $this->mapper->getContentType()));
     } catch (HttpClient_HttpStatusException $e) {
         $message = $e->getMessage();
         if ($e->getCode() == 403 || $e->getCode() == 422) {
             $this->errors = $this->mapper->mapFromStorage($this->transport->getLastResponse());
             if ($this->errors instanceof Error_Array && count($this->errors) > 0) {
                 $message .= PHP_EOL . 'Errors:' . PHP_EOL . $this->errors;
             }
         }
         if (self::$debug) {
             printf('Url: %s' . PHP_EOL . 'Method: %s' . PHP_EOL . 'Data: %s', $url, $method, $data);
         }
         switch ($e->getCode()) {
             case 401:
                 throw new NotLoggedInException($message, 0, $e);
                 break;
             case 403:
                 throw new ForbiddenException($message, 0, $e);
                 break;
             case 404:
                 throw new NotFoundException($message, 0, $e);
                 break;
             case 406:
             case 422:
                 throw new NotValidException($message, 0, $e);
                 break;
             default:
                 $message = 'Unknown error';
                 // no break
             // no break
             case 500:
             case 501:
                 throw new ServerErrorException($message, 0, $e);
                 break;
         }
     }
     return $response;
 }
예제 #4
0
  public function sms() {                                                      // the main sub in our application
   include_once("model/transport.php");       // connect to the Settings 
   
   if(!isset($_SESSION)) session_start();
   
   $action = getvariablereq('action');          // get action from the request
   $data   = getvariablereq('data'  );          // get JSON data from the request
   
   $t = $this->model->getStats('common');
   
   echo "Report date: ".date("Y-m-d H:i:s")."<br>";
   
   $phones_first  = array();	
   $phones_second = array();	
   $users=$this->model->getUsersSms();
   $this->model->resetUsersFirstSms();
   
//   ajax_echo_r ($users);
   
   foreach ($users as $user) {
    if ($user->Phone) {
     $user->Phone = str_replace("+7", "8", $user->Phone);
     $user->Phone = str_replace( "-",  "", $user->Phone);
     
     if ($user->FirstSms) {
      $phones_first[]  .= $user->Phone;
     } else {
      $phones_second[] .= $user->Phone;
     }
    }
   }
   
   $info = "Всего собственников ".$t->objects_total.", из них новых ".$t->objects_yesterday.". Всего покупателей ".$t->customers_total.", из них новых ".$t->customers_yesterday.". ";
//   $info.= "Потенциальных сделок ".$t->handshakes_auto.". ";
   $info.= "Сделок на этой неделе ".$t->handshakes_thisweek." (осталось сделать  ".($t->handshakes_thisweek_plan - $t->handshakes_thisweek).").";
   
   echo $info;
   
   $api = new Transport($this->settings);
   $params_first  = array(
    "text" => "Привет, это СМСка от Изума. ".$info
   );
   $params_second = array(
    "text" => "Доброе утро. Изум-информ сообщает: ".$info
   );
   
//   $phones_first  = array('89376411426');
//   $phones_second = array('89276047754');
   
   ajax_echo_r ($phones_first);
   ajax_echo_r ($phones_second);
   
   $send_first  = $api->send($params_first  ,$phones_first);
   $send_second = $api->send($params_second ,$phones_second);
   
   ajax_echo_r ($send_first);
   ajax_echo_r ($send_second);
   
   if ($send['code'] == 1) {
//    echo 'Отправлено '.$send['colSendAbonent'].', не отправлено';
   } else {
//    echo $send['descr'];
   }
   
   
   
  }
예제 #5
0
            mail("{$email}", "{$theme}", "{$message}", $headers);
        }
        /*отправляем пароль на почту К*/
        //отправка смс. http://lcab.smsprofi.ru
        $tel_mngr = array('+79094107400', '+79287589546');
        //$tel_mngr=array('+79043496688');
        require_once "sms/transport.php";
        $api = new Transport();
        if ($level == 1) {
            $mesg = translit("{$famil} {$name}({$tel}) {$address}");
        }
        if ($level == 2) {
            $mesg = translit("ODOBREN! {$famil} {$name}({$tel}) {$address}");
        }
        $params = array("text" => $mesg, "source" => "lady style", "use_alfasource " => "1");
        $send = $api->send($params, $tel_mngr);
        unset($name);
        $name = NULL;
        unset($_POST['pw']);
        unset($_POST['name']);
        unset($_POST['famil']);
        unset($_POST['email']);
        unset($_POST['captcha']);
        if (!$result) {
            die("<hr>Сбой при доступе к базе данных: <br>" . mysql_error());
        }
        echo "<script>\n                    window.location = \"http://www.ladystyle.su/auth/reg_accepted.php?user_uniq={$user_uniq}&lev={$level}\"\n                    </script>\n                    }";
    } else {
        echo "<h2>Что-то пошло не так :(<br> Возможно, не верно введены цифры с картинки?</h2><br>\t<a href=\"javascript:history.back()\" onMouseOver=\"window.status='Назад';return true\"><h3>Повторить ввод<h3></a>";
    }
} else {
예제 #6
0
 /**
  * @param $text
  * @param $contact
  * @param $message_id
  * @return bool|float
  */
 public function editMessage($text, $contact, $message_id)
 {
     return $this->transport->send($contact, $text, $message_id);
 }
예제 #7
0
 /**
  * @param Notification $notification
  * @return void
  */
 public function send(Notification $notification)
 {
     $this->transport->send($notification);
 }