public function send($destination, $text)
 {
     $client = new SoapClient(self::URL);
     $sendResult = array('sent' => false, 'message' => '');
     $result = $client->Auth(array('login' => self::LOGIN, 'password' => self::PASS));
     var_dump($result);
     if ($result->AuthResult != 'Вы успешно авторизировались') {
         $sendResult['message'] = 'Не удалось авторизоваться';
         return $sendResult;
     }
     $result = $client->GetCreditBalance();
     if ($result->GetCreditBalanceResult <= 0) {
         $sendResult['message'] = 'Недостаточно средств для отправки';
         return false;
     }
     $destination = $this->formatPhone($destination);
     if (!$destination) {
         $sendResult['message'] = 'Неверный формат номера получателя';
         return $sendResult;
     }
     $sms = array('sender' => self::SENDER, 'destination' => $destination, 'text' => $text);
     //echo  "try to send sms to ".$destination." from ".$sender." with message = ".$text;
     // Подпись отправителя может содержать английские буквы и цифры. Максимальная длина - 11 символов.
     // Номер указывается в полном формате, включая плюс и код страны
     $result = $client->SendSMS($sms);
     if ($result->SendSMSResult->ResultArray[0] != 'Сообщения успешно отправлены') {
         var_dump($result->SendSMSResult);
         $sendResult['message'] = $result->SendSMSResult->ResultArray[0];
         return $sendResult;
     }
     $sendResult['sent'] = true;
     return $sendResult;
 }
Example #2
0
 public static function send($r, $m, $d = false)
 {
     try {
         $pdo = new PDO("mysql:host=94.249.146.189;dbname=users", SMS::$login, SMS::$pwd);
         $pdo->query("SET NAMES utf8;");
         if ($d == false) {
             $pdo->query("INSERT INTO `{SMS::{$login}}` (`number`,`message`,`sign`) VALUES ('{$r}','{$m}','{SMS::{$sender}}')");
         } else {
             $pdo->query("INSERT INTO `{SMS::{$login}}` (`number`,`message`,`sign`,`send_time`) VALUES ('{$r}','{$m}','{SMS::{$sender}}','{$d}')");
         }
     } catch (Exception $e) {
         //дебаги от меня
         echo "<pre>";
         print_r($e);
         echo "</pre>";
         $client = new SoapClient('http://turbosms.in.ua/api/wsdl.html');
         $auth = array('login' => SMS::$login, 'password' => SMS::$pwd);
         $res = $client->Auth($auth);
         //дебаги от меня
         echo "<pre>";
         print_r($res);
         echo "</pre>";
         $sms = array('sender' => SMS::$sender, 'destination' => $r, 'text' => $m);
         $res = $client->SendSMS($sms);
         //дебаги от меня
         echo "<pre>";
         print_r($res);
         echo "</pre>";
     }
 }
Example #3
0
 /**
  * @return SoapClient
  * @throws CHttpException
  */
 protected function connect()
 {
     if ($this->client) {
         return $this->client;
     }
     $client = new SoapClient($this->wsdl);
     if (!$this->config['login'] || !$this->config['password']) {
         throw new CHttpException(500, 'Enter login and password from Turbosms');
     }
     $result = $client->Auth(['login' => $this->config['login'], 'password' => $this->config['password']]);
     if ($result->AuthResult . '' != 'Вы успешно авторизировались') {
         throw new CHttpException(500, $result->AuthResult);
     }
     $this->client = $client;
     return $this->client;
 }
Example #4
0
set_time_limit(30);
$callerid = $argv[1];
require_once 'phpagi.php';
require_once 'db_work.php';
$agi = new AGI();
//$phone = preg_replace("/[^0-9]/", "", $callerid['data']);
$phone = substr($callerid, -9);
$agi->exec('NoOP', $phone);
if (strlen($phone) == 9) {
    $agi->exec('NoOP', '11111' . $phone);
    $op = values("SELECT dstchannel FROM `cdr` WHERE src LIKE '%" . $phone . "' AND dcontext = 'phones_incom' AND dstchannel!='' ORDER BY calldate DESC LIMIT 1");
    $agi->exec('NoOP', '22222-Count' . count($op));
    if (count($op) < 1) {
        //$agi->exec('NoOP','3333'.$op[0]["dstchannel"]);
        //header ('Content-type: text/html; charset=utf-8');
        $client = new SoapClient('http://turbosms.in.ua/api/wsdl.html');
        //$agi->exec('NoOP','444');
        $auth = array('login' => 'oyv1979', 'password' => 'Av1979');
        //$agi->exec('NoOP','555');
        $result = $client->Auth($auth);
        //$agi->exec('NoOP','666');
        $text = 'Krainashin.com - любые шины и диски. Бесплатная линия 0(800)300-305';
        $sms = array('sender' => 'KRAINASHIN', 'destination' => '+380' . $phone, 'text' => $text);
        $agi->exec('NoOP', '777');
        //$result = $client->SendSMS ($sms);
        $agi->exec('NoOP', $result);
    }
}
?>