예제 #1
0
 public function send($to, $message, $sender = NULL)
 {
     $client = new \SMSApi\Client($this->username);
     $client->setPasswordHash($this->password);
     $smsapi = new \SMSApi\Api\SmsFactory();
     $smsapi->setClient($client);
     try {
         $actionSend = $smsapi->actionSend();
         if ($this->options['special_chars']) {
             $actionSend->setNormalize(1);
         }
         if ($this->options['fast']) {
             $actionSend->setFast(1);
         }
         if ($sender && $sender != 'DEFAULT') {
             $actionSend->setSender($sender);
         } elseif ($sender == NULL) {
             if ($this->db_sender != 'DEFAULT') {
                 $actionSend->setSender($this->db_sender);
             }
         }
         $actionSend->setTo($to);
         $actionSend->setText($message);
         $actionSend->execute();
     } catch (\SMSApi\Exception\SmsapiException $e) {
         return $e->getMessage();
     }
     return TRUE;
 }
예제 #2
0
function sendSms($contactNumber, $text)
{
    $client = new \SMSApi\Client('p1990');
    $client->setPasswordHash('05a8f2bdae0d9c84cb57fcbf2b9c74e2');
    $smsapi = new \SMSApi\Api\SmsFactory();
    $smsapi->setClient($client);
    try {
        $actionSend = $smsapi->actionSend();
        $actionSend->setTo($contactNumber);
        $actionSend->setText($text);
        $actionSend->setSender('ECO');
        //Pole nadawcy, lub typ wiadomości: 'ECO', '2Way'
        $response = $actionSend->execute();
        foreach ($response->getList() as $status) {
            return $status->getNumber() . ' ' . $status->getStatus();
        }
    } catch (\SMSApi\Exception\SmsapiException $exception) {
        echo 'ERROR: ' . $exception->getMessage();
    }
}