public function send(MessageInterface $message, $skipErrors = true) {
        $smsapi = new SmsFactory();
        $smsapi->setClient($this->getClient());

        $actionSend = $smsapi->actionSend();

        // Name of the sender must be defined in SMSApi admin panel first.
        // If $sender is set to "ECO", then the ECO SMS will be send
        $sender = $this->getParam('sender');
        if (empty($sender)) {
            throw new ConfigurationException(__CLASS__ . ' is not configured properly. Please set "sender" parameter properly.');
        }
        $actionSend->setSender($sender);

        $actionSend->setText($message->getText());
        foreach ($message->getRecipient() as $recipient) {
            try {
                $actionSend->setTo($recipient); // Numer odbiorcy w postaci 48xxxxxxxxx lub xxxxxxxxx

                $response = $actionSend->execute();

                foreach ($response->getList() as $status) {
                    // @see https://www.smsapi.pl/statusy-wiadomosci
                    if (in_array($status->getStatus(), [407, 406, 405, 401, 402])) {
                        $this->addError(new SendingError($status->getNumber(), $status->getStatus(), $status->getError()));
                        if (!$skipErrors) {
                            throw new \RuntimeException($status->getError(), $status->getStatus());
                        }
                    }
                }
            }
            catch (SmsapiException $e) {
                $this->addError(new SendingError($recipient, $e->getCode(), $e->getMessage()));
                if (!$skipErrors) {
                    throw new \RuntimeException($e->getMessage(), $e->getCode(), true);
                }
            }
        }
        return $this->getErrors()->count() === 0;
    }
public function send(MessageInterface $message, $skipErrors = true) {
        $smsapi = new SmsFactory();
        $smsapi->setClient($this->getClient());

        $actionSend = $smsapi->actionSend();

        // Name of the sender must be defined in SMSApi admin panel first.
        // If $sender is set to "ECO", then the ECO SMS will be send
        $sender = $this->getParam('sender');
        if (empty($sender)) {
            throw new ConfigurationException(__CLASS__ . ' is not configured properly. Please set "sender" parameter properly.');
        }
        $actionSend->setSender($sender);

        $actionSend->setText($message->getText());
        foreach ($message->getRecipient() as $recipient) {
            try {
                $actionSend->setTo($recipient); // Numer odbiorcy w postaci 48xxxxxxxxx lub xxxxxxxxx

                $response = $actionSend->execute();

                foreach ($response->getList() as $status) {
                    // @see https://www.smsapi.pl/statusy-wiadomosci
                    if (in_array($status->getStatus(), [407, 406, 405, 401, 402])) {
                        $this->addError(new SendingError($status->getNumber(), $status->getStatus(), $status->getError()));
                        if (!$skipErrors) {
                            throw new \RuntimeException($status->getError(), $status->getStatus());
                        }
                    }
                }
            }
            catch (SmsapiException $e) {
                $this->addError(new SendingError($recipient, $e->getCode(), $e->getMessage()));
                if (!$skipErrors) {
                    throw new \RuntimeException($e->getMessage(), $e->getCode(), true);
                }
            }
        }
        return $this->getErrors()->count() === 0;
    }
public function send ( MessageInterface $ message , $ skipErrors = true ) { $ smsapi = new SmsFactory ( ) ; $ smsapi -> setClient ( $ this -> getClient ( ) ) ; $ actionSend = $ smsapi -> actionSend ( ) ; // Name of the sender must be defined in SMSApi admin panel first. // If $sender is set to "ECO", then the ECO SMS will be send $ sender = $ this -> getParam ( 'sender' ) ; if ( empty ( $ sender ) ) { throw new ConfigurationException ( __CLASS__ . ' is not configured properly. Please set "sender" parameter properly.' ) ; } $ actionSend -> setSender ( $ sender ) ; $ actionSend -> setText ( $ message -> getText ( ) ) ; foreach ( $ message -> getRecipient ( ) as $ recipient ) { try { $ actionSend -> setTo ( $ recipient ) ; // Numer odbiorcy w postaci 48xxxxxxxxx lub xxxxxxxxx $ response = $ actionSend -> execute ( ) ; foreach ( $ response -> getList ( ) as $ status ) { // @see https://www.smsapi.pl/statusy-wiadomosci if ( in_array ( $ status -> getStatus ( ) , [ 407 , 406 , 405 , 401 , 402 ] ) ) { $ this -> addError ( new SendingError ( $ status -> getNumber ( ) , $ status -> getStatus ( ) , $ status -> getError ( ) ) ) ; if ( ! $ skipErrors ) { throw new \ RuntimeException ( $ status -> getError ( ) , $ status -> getStatus ( ) ) ; } } } } catch ( SmsapiException $ e ) { $ this -> addError ( new SendingError ( $ recipient , $ e -> getCode ( ) , $ e -> getMessage ( ) ) ) ; if ( ! $ skipErrors ) { throw new \ RuntimeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , true ) ; } } } return $ this -> getErrors ( ) -> count ( ) === 0 ; }
Send message through SmsApi.pl gateway
@param SmsMessageModel $message
@return bool
Send message through SmsApi . pl gateway