Sends an SMS.

@param Sms $sms

@return Response[]

@throws EmptyResponseException
@throws NoRecipientsSpecifiedException
@throws UnknownErrorResponseException
970868
public function send(Sms $sms): array
    {
        if (! $sms->hasRecipients()) {
            throw new NoRecipientsSpecifiedException();
        }

        $messages = [];

        $recipients = $sms->getRecipients();
        foreach (array_chunk($recipients, Recipients::MAX) as $chunk) {
            $message = clone $sms;
            $message
                ->setRecipients($chunk)
                ->clearRecipientVariables()
            ;

            foreach ($chunk as $recipient) {
                if (! isset($sms->getRecipientVariables()[$recipient])) {
                    continue;
                }

                foreach ($sms->getRecipientVariables()[$recipient] as $variable => $value) {
                    $message->addRecipientVariable($recipient, $variable, $value);
                }
            }

            $messages[] = $message;
        }

        $responses = [];
        foreach ($messages as $message) {
            $request = $this->prepareRequest($message);

            $responses[] = $this->executeRequest($request);
        }

        return $responses;
    }
935042
public function send($authyId, $method = 'sms', $force = false, $action = null, $actionMessage = null): Response
    {
        // Prepare required variables
        $url = $this->api.$method."/{$authyId}";
        $params = $this->params + ['query' => ['force' => $force ? 'true' : 'false', 'action' => $action, 'actionMessage' => $actionMessage]];

        // Send Authy token, and return response
        return new Response($this->http->get($url, $params));
    }
155106
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;
    }
1141075
public static sent_sms[] get_filtered(nitro_service service, String filter) throws Exception
	{
		sent_sms obj = new sent_sms();
		options option = new options();
		option.set_filter(filter);
		sent_sms[] response = (sent_sms[]) obj.getfiltered(service, option);
		return response;
	}
696625
def send(self, messages):
        """"""

        tmpSms = SMS(to='', message='')
        if str(type(messages)) == str(type(tmpSms)):
            messages = [messages]

        xml_root = self.__init_xml('Message')
        wrapper_id = 0

        for m in messages:
            m.wrapper_id = wrapper_id
            msg = self.__build_sms_data(m)
            sms = etree.SubElement(xml_root, 'SMS')
            for sms_element in msg:
                element = etree.SubElement(sms, sms_element)
                element.text = msg[sms_element]

        # print etree.tostring(xml_root)
        response = clockwork_http.request(SMS_URL, etree.tostring(xml_root, encoding='utf-8'))
        response_data = response['data']

        # print response_data
        data_etree = etree.fromstring(response_data)

        # Check for general error
        err_desc = data_etree.find('ErrDesc')
        if err_desc is not None:
            raise clockwork_exceptions.ApiException(err_desc.text, data_etree.find('ErrNo').text)

        # Return a consistent object
        results = []
        for sms in data_etree:
            matching_sms = next((s for s in messages if str(s.wrapper_id) == sms.find('WrapperID').text), None)
            new_result = SMSResponse(
                sms = matching_sms,
                id = '' if sms.find('MessageID') is None else sms.find('MessageID').text,
                error_code = 0 if sms.find('ErrNo') is None else sms.find('ErrNo').text,
                error_message = '' if sms.find('ErrDesc') is None else sms.find('ErrDesc').text,
                success = True if sms.find('ErrNo') is None else (sms.find('ErrNo').text == 0)
            )
            results.append(new_result)

        if len(results) > 1:
            return results

        return results[0]
1082858
def send_sms(body, from_phone, to, flash=False, fail_silently=False,
             auth_user=None, auth_password=None, connection=None):
    
    from sendsms.message import SmsMessage
    connection = connection or get_connection(
        username = auth_user,
        password = auth_password,
        fail_silently = fail_silently
    )
    return SmsMessage(body=body, from_phone=from_phone, to=to, \
        flash=flash, connection=connection).send()
241603
public function sendMessage($message) {
		$message = preg_replace("/(\n\r|\n)/","\r",$message);
		$query = http_build_query(array(
			'user' => $this->_user_id,
			'pass' => $this->_api_key,
			'msg' => $message
		));
		$url = self::api_url.'?'.$query;

		$curl_handler = curl_init();
		curl_setopt($curl_handler,CURLOPT_URL,$url);
		curl_setopt($curl_handler,CURLOPT_POST,false);
		curl_setopt($curl_handler,CURLOPT_RETURNTRANSFER,true);
		curl_setopt($curl_handler,CURLOPT_HEADER,true);
		curl_setopt($curl_handler,CURLOPT_NOBODY,true);
		curl_setopt($curl_handler,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($curl_handler,CURLOPT_SSL_VERIFYPEER,true);
		curl_setopt($curl_handler,CURLOPT_SSL_VERIFYHOST,2);
		curl_setopt($curl_handler,CURLOPT_CAINFO,__DIR__."/freemobile.crt");
		
		if (curl_exec($curl_handler) === false) {
			throw new Exception('Curl error : '.curl_error($curl_handler));
		}
		
		$status = curl_getinfo($curl_handler,CURLINFO_HTTP_CODE);
		curl_close($curl_handler);

		switch ($status) {
		case 200:
			return true;
			break;

		case 400:
			throw new Exception('Badly formed request');
			return false;
			break;

		case 402:
			throw new OverflowException('Too many messages sent in a short period of time');
			return false;
			break;

		case 403:
			throw new UnexpectedValueException('SMS notification service not activated or wrong credentials');
			return false;
			break;

		case 500:
			throw new RuntimeException('Server error, try later');
			return false;
			break;
			
		default:
			return false;
			break;
		}
	}
733426
private function prepareRecipients(Sms $sms): string
    {
        $recipients = $sms->getRecipients();

        if (! $sms->hasRecipientVariables()) {
            $recipients = array_map([$this, 'normalizePhoneNumber'], $recipients);

            return json_encode($recipients);
        }

        $recipientVariables = $sms->getRecipientVariables();

        return json_encode(array_map(function ($recipient) use ($recipientVariables) {
            $targetVariables = [];
            if (isset($recipientVariables[$recipient])) {
                $targetVariables = $recipientVariables[$recipient];
            }

            return array_merge(['recipient' => $this->normalizePhoneNumber($recipient)], $targetVariables);
        }, $recipients));
    }
718966
public function sendSMSResponse()
     {
        $response = new StdClass;
        $response->status = 'Sent';
        $response->message_id = $this->getValidMessageID();
        $response->sms_credits_used = 1;

        return $response;
     }
987006
public function PostSmsMessagesSendTo(XsString $telephoneNumber, ApiSms $apiSms)
    {
        $this->execute(sprintf("/sms-messages/send-to/%s", $telephoneNumber), 'POST', $apiSms->toJson());
    }
478745
public void sendMessage(final SMSBroker sms) {
		
		final int smsId = sms.getId();
		final String smsRecipient = sms.getRecipient();
		final String smsMessage = sms.getMessage();
		
		if (logger.isDebugEnabled()) {
			logger.debug("Entering into send message with parameter : ");
			logger.debug("   - message id : " + smsId);
			logger.debug("   - message recipient : " + smsRecipient);
			logger.debug("   - message : " + smsMessage);
		}
		
		try {
			final String messageISOLatin = new String(smsMessage.getBytes(),"ISO-8859-1");
			if (logger.isDebugEnabled()) {
				logger.debug("sending encoded message : " + messageISOLatin);
			}

			final SMText smText = RequestFactory.createSMText(smsId, smsRecipient, messageISOLatin);
			smText.setNotificationLevel(NOTIFICATION_LEVEL);
			
			// only send the message if required
			if (!simulateMessageSending) {
				olmConnector.submit(smText);
                logger.debug("message with : " + " - id : " + smsId + "successfully sent");
			} else {
				logger.warn("Message with id : " + smsId + " not sent because simlation mode is enable");
			}

			
		} catch (Throwable t) {
			logger.error("An error occurs sending SMS : " + 
				     " - id : " + smsId + 
				     " - recipient : " + smsRecipient + 
				     " - message : " + smsMessage);
		}		

	}
952323
public function send($destination, Message $message)
    {
        return $this->getClient()->send($destination, $message, ['transaction' => $this->transactionId], false);
    }
744149
public function send($message, $recipient, $mustInit = true)
    {
        if ($mustInit) $this->_init();

        $params = array(
            'api' => $this->api_key,
            'number' => $recipient,
            'message' => $message,
            'from' => $this->from,
        );

        $query = http_build_query($params);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, Config::get('semaphore::url.sms.sms'));
        curl_setopt($ch, CURLOPT_POST, count($params));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);

        return $response;
    }
1063166
public function send($mobile, $content) {
        $data = $this->getSend()->parameters([
            'mobile' => $mobile,
            'content' => $content,
            'method' => 'Submit'
        ])->json();
        if ($data['code'] == 2) {
            return $data['smsid'];
        }
        throw new \Exception($data['msg']);
    }
1170501
public function send(OutgoingMessage $message)
    {
        $from = $message->getFrom();
        $composeMessage = $message->composeMessage();

        $numbers = $message->getToWithCarriers();

        if (count($numbers) > 1) {
            $endpoint = '/send-sms-multiple';
            $data = [
                'sendSmsMultiRequest' => ['sendSmsRequestList' => []],
            ];

            foreach ($numbers as $key => $item) {
                array_push($data['sendSmsMultiRequest']['sendSmsRequestList'],
                    $this->generateMessageBody($from, $item, $composeMessage));
            }
        } else {
            $endpoint = '/send-sms';
            $data = [
                'sendSmsRequest' => $this->generateMessageBody($from, $numbers[0], $composeMessage),
            ];
        }

        $this->buildCall($endpoint);
        $this->buildBody($data);

        $this->postRequest();
    }
82580
function it_generates_the_expected_request_when_sending_sms(){

        //---------------------------------
        // Test Setup

        $payload = [
            'phone_number' => '+447834000000',
            'template_id'=> 118,
            'personalisation' => [
                'name'=>'Fred'
            ]
        ];

        $this->httpClient->sendRequest( Argument::type('Psr\Http\Message\RequestInterface') )->willReturn(
            new Response(
                201,
                [ 'Content-type'  => 'application/json' ],
                json_encode([ 'notification_id' => 'xxx' ])
            )
        );

        //---------------------------------
        // Perform action

        $this->sendSms( $payload['phone_number'], $payload['template_id'], $payload['personalisation'] );

        //---------------------------------
        // Check result

        $this->httpClient->sendRequest( Argument::that(function( $v ) use ($payload) {

            // Check a request was sent.
            if( !( $v instanceof RequestInterface ) ){
                return false;
            }

            // With the correct URL
            if( $v->getUri() != self::BASE_URL . Client::PATH_NOTIFICATION_SEND_SMS ){
                return false;
            }

            // Include the correct token header
            if( $v->getHeader('Authorization') != [ 'Bearer '.self::TEST_JWT_TOKEN ] ){
                return false;
            }

            // And correct Content-type
            if( $v->getHeader('Content-type') != [ 'application/json' ] ){
                return false;
            }

            // With the expected body.
            if( json_decode( $v->getBody(), true ) != $payload ){
                return false;
            }

            return true;

        }))->shouldHaveBeenCalled();

    }
288765
public function send()
    {
        // Convert body to hex when the message is binary
        if ($this->isBinary()) {
            $this->postFields['body'] = strtoupper(bin2hex($this->body));
        }

        $response = $this->sendApiCall(self::ACTION_CREATE, $this->getCreateUrl());

        if (!isset($response->getBody()['_embedded']['items'])) {
            throw new Exception('Invalid response returned from server', Exception::INVALID_RESPONSE);
        }

        $result = array();
        foreach ($response->getBody()['_embedded']['items'] as $item) {
            $result[] = $sms = new Sms($this->client, $this->factory);
            $sms->setFields($item);
        }

        return $result;
    }