示例#1
0
 /**
  * {@inheritdoc}
  */
 public function sendSMS(SMSInterface $sms)
 {
     $id = rand();
     $sms->setMessageId(rand());
     $response = new BaseSentResponse($sms, 1);
     $response->setData(array('id' => $id));
     $response->setMessageId($id);
     return $response;
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function sendSMS(SMSInterface $sms)
 {
     $data = $this->httpClient->post($this->urlUtils->buildUrlString($this->getApiBaseUrl(), '/sms/json'), array('content-type' => 'application/json'), json_encode(array('api_key' => $this->getApiUser(), 'api_secret' => $this->getApiToken(), 'type' => 'text', 'from' => $sms->getFrom(), 'to' => $sms->getTo(), 'text' => urlencode(utf8_encode($sms->getText())))))->send()->json();
     $sms->setMessageId($data['message-id']);
     $response = new BaseSentResponse($sms, $data['message-count']);
     $response->setData($data);
     // TODO clearify usage of other messages
     $response->setMessageId($data['messages'][0]['message-id']);
     $response->setInternalId($data['messages'][0]['client-ref']);
     return $response;
 }
 /**
  * {@inheritdoc}
  */
 public function sendSMS(SMSInterface $sms)
 {
     $toNumber = '' . $sms->getTo();
     if (substr($toNumber, 0, 2) == '00') {
         $toNumber = substr($toNumber, 2);
         $toNumber = substr($toNumber, 0, 15);
     }
     try {
         $body = $this->httpClient->get($this->urlUtils->buildUrlString($this->getApiBaseUrl(), '/sendsms'), null, array('query' => array('user' => $this->getApiUser(), 'password' => $this->getApiToken(), 'from' => $sms->getFrom(), 'to' => $toNumber, 'body' => mb_convert_encoding($sms->getText(), 'ISO-8859-15', mb_detect_encoding($sms->getText())))))->send()->getBody(true);
     } catch (RequestException $ex) {
         throw new DeliveryFailedException($ex->getMessage(), 0, $ex);
     }
     $data = $this->urlUtils->parseNewLineSeparatedBody($body);
     $sms->setMessageId($data['id']);
     $response = new BaseSentResponse($sms, 1);
     $response->setData($body);
     $response->setMessageId($data['id']);
     return $response;
 }