/** * Prepare client configuration * @return Client * @throws ConfigurationException */ private function getClient() { $login = $this->getParam('login'); $password = $this->getParam('password'); $sender = $this->getParam('sender'); if (empty($sender) || (empty($login) || empty($password))) { throw new ConfigurationException(__CLASS__ . ' is not configured properly. Please set "sender" and "login" and "password" parameters properly.'); } return Sender::create($login, md5($password), $sender); }
public function send(Message $message, PhoneNumber $recipient) { $number = $recipient->getCountryCode() . $recipient->getNationalNumber(); $text = $message->getContent(); try { $maxLen = $message->getType() === Message::TYPE_ASCII ? self::MAX_LENGTH_ASCII : self::MAX_LENGTH_UNICODE; $textPreparedForSms = $this->transport->prepareTextForMessage($text); if (mb_strlen($textPreparedForSms) > $maxLen) { $text = $this->transport->splitMessage($textPreparedForSms, $maxLen); $text = array_map($this->transport, $text); } if (false === is_array($text)) { $text = array($text); } foreach ($text as $contentPart) { $this->sender->sendMessage($number, $contentPart, $this->getTypeForMessage($message)); } return true; } catch (MobitexException $e) { throw new SenderException($e->getMessage(), $e->getCode(), $e); } }