Example #1
0
 /**
  * Выполняет отправку сообщения
  *
  * @param boolean $json Возвращать ответ в JSON
  * @throws \Exception
  * @return mixed|string
  */
 public function send($json = true)
 {
     if ($this->message instanceof PhpSms\Message) {
         $params = array('api_id' => $this->apiId, 'from' => $this->message->getFrom(), 'to' => $this->message->getTo(), 'text' => $this->message->getText());
         return $this->api('sms/send', $params);
     } else {
         throw new \Exception('Message is required');
     }
 }
Example #2
0
 /**
  * Выполняет отправку сообщения
  *
  * @param boolean $json Возвращать ответ в JSON
  * @throws \Exception
  * @return mixed|string
  */
 public function send($json = true)
 {
     if ($this->message instanceof PhpSms\Message) {
         $params = array('user' => $this->user, 'password' => $this->password, 'to' => $this->message->getTo(), 'text' => $this->message->getText(), 'from' => $this->message->getFrom());
         if ($json) {
             $params['answer'] = 'json';
         }
         $result = $this->api('send', $params);
         return $json ? json_decode($result, true) : $result;
     } else {
         throw new \Exception('Message is required');
     }
 }