Send a premium SMS

@param $shortcode
@param $keyword
@param $tariff
@param $mid
@param $member
6127
public function setPremiumSms($shortcode, $keyword, $tariff, $mid = null, $member = null)
    {
        $this->typeDetails['shortcode'] = $shortcode;
        $this->typeDetails['keyword']   = $keyword;
        $this->typeDetails['tariff']    = $tariff;
        if ($mid != null) {
            $this->typeDetails['mid'] = $mid;
        }
        if ($member != null) {
            $this->typeDetails['member'] = $member;
        }

        $this->type = self::TYPE_PREMIUM;
    }
291753
public function preSend()
    {
        try {
            $this->mailHeader = '';
            if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
                throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
            }

            // Set whether the message is multipart/alternative
            if (!empty($this->AltBody)) {
                $this->ContentType = 'multipart/alternative';
            }

            $this->error_count = 0; // reset errors
            $this->setMessageType();
            // Refuse to send an empty message unless we are specifically allowing it
            if (!$this->AllowEmpty and empty($this->Body)) {
                throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
            }

            $this->MIMEHeader = $this->createHeader();
            $this->MIMEBody = $this->createBody();

            // To capture the complete message when using mail(), create
            // an extra header list which createHeader() doesn't fold in
            if ($this->Mailer == 'mail') {
                if (count($this->to) > 0) {
                    $this->mailHeader .= $this->addrAppend('To', $this->to);
                } else {
                    $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
                }
                $this->mailHeader .= $this->headerLine(
                    'Subject',
                    $this->encodeHeader($this->secureHeader(trim($this->Subject)))
                );
            }

            // Sign with DKIM if enabled
            if (!empty($this->DKIM_domain)
                && !empty($this->DKIM_private)
                && !empty($this->DKIM_selector)
                && !empty($this->DKIM_domain)
                && file_exists($this->DKIM_private)) {
                $header_dkim = $this->DKIM_Add(
                    $this->MIMEHeader . $this->mailHeader,
                    $this->encodeHeader($this->secureHeader($this->Subject)),
                    $this->MIMEBody
                );
                $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF .
                    str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
            }
            return true;

        } catch (phpmailerException $exc) {
            $this->setError($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }
            return false;
        }
    }
793093
public function register( $context = null ) {
		if ( ! $this->is_needed() ) {
			return;
		}

		\shortcode_ui_register_for_shortcode(
			$this->shortcode_tag,
			$this->config
		);
	}
1353586
public function sendApiRest($code=200, $jsonString= '', $contentType='application/json'){
        $this->setStatusCode($code);
        $this->setContentType($contentType);
        $this->setContent($jsonString);
        $this->sendContent();
    }
370492
public function send($phone, $text, $gate, $id) {
		$params = array(
			'phone' => $phone,
			'text' => $text,
			'gate' => $gate,
			'id' => $id
		);
		return $this->master->call('premium/send', $params);
	}
92321
protected function sendEmail($member, $token)
    {
        /** @var Email $email */
        $email = Email::create()
            ->setHTMLTemplate('SilverStripe\\Control\\Email\\ForgotPasswordEmail')
            ->setData($member)
            ->setSubject(_t(
                'SilverStripe\\Security\\Member.SUBJECTPASSWORDRESET',
                "Your password reset link",
                'Email subject'
            ))
            ->addData('PasswordResetLink', Security::getPasswordResetLink($member, $token))
            ->setTo($member->Email);
        return $email->send();
    }
987006
public function PostSmsMessagesSendTo(XsString $telephoneNumber, ApiSms $apiSms)
    {
        $this->execute(sprintf("/sms-messages/send-to/%s", $telephoneNumber), 'POST', $apiSms->toJson());
    }
786144
public function sendChatActionReply(): SendChatAction
	{
		$m = $this->bot->sendChatAction();
		$this->setReplyMarkup($m, false);
		return $m;
	}
208798
public static String sendCoupon(Map<String, String> params, String certPath, String certPassword) {
		return doPostSSL(SEND_COUPON_URL, params, certPath, certPassword);
	}
529893
def send_sms(profile, body, to, from_):
    '''
    
    '''
    ret = {}
    ret['message'] = {}
    ret['message']['sid'] = None
    client = _get_twilio(profile)
    try:
        if TWILIO_5:
            message = client.sms.messages.create(body=body, to=to, from_=from_)
        else:
            message = client.messages.create(body=body, to=to, from_=from_)
    except TwilioRestException as exc:
        ret['_error'] = {}
        ret['_error']['code'] = exc.code
        ret['_error']['msg'] = exc.msg
        ret['_error']['status'] = exc.status
        log.debug('Could not send sms. Error: %s', ret)
        return ret
    ret['message'] = {}
    ret['message']['sid'] = message.sid
    ret['message']['price'] = message.price
    ret['message']['price_unit'] = message.price_unit
    ret['message']['status'] = message.status
    ret['message']['num_segments'] = message.num_segments
    ret['message']['body'] = message.body
    ret['message']['date_sent'] = six.text_type(message.date_sent)
    ret['message']['date_created'] = six.text_type(message.date_created)
    log.info(ret)
    return ret
1079718
public function shortCode($shortcode, $action)
    {
        return $this->getMocaBonita()->addMbShortcode($shortcode, $this->getMbPage(), $action);
    }
519023
public function send(string $to, Sms $sms, array $params = []): bool
    {
        $content = $sms->content($this->agent_name);
        if (!$content) {
            $this->result->setStatus(false)->setMessage('The agent : ' . $this->agent_name . ' not supported by SMS');
            return false;
        }

        $send_params = [
            'RegionId' => self::ENDPOINT_REGION,
            'AccessKeyId' => $this->config['access_key_id'],
            'Format' => 'JSON',
            'SignatureMethod' => 'HMAC-SHA1',
            'SignatureVersion' => '1.0',
            'SignatureNonce' => uniqid(),
            'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'),
            'Action' => 'SendSms',
            'Version' => '2017-05-25',
            'PhoneNumbers' => $to,
            'SignName' => SmsConfig::getSign(),
            'TemplateCode' => $content,
            'TemplateParam' => json_encode($params, JSON_FORCE_OBJECT),
            'OutId' => '',
        ];
        $send_params['Signature'] = $this->signature($send_params);

        $curl = new CurlRequest();
        list($code,$res) = $curl->request('POST',self::ENDPOINT_URL,['body' =>$send_params ]);

        $this->result->setReceiptData($res)->setContent($content)->setParams($params);

        $receipt_data = json_decode($res,true);
        if ($receipt_data === false) {
            $this->result->setStatus(false)->setMessage('Request failed!');
            return false;
        }
        $this->result->setMessage($receipt_data['Message'])->setReceiptId($receipt_data['RequestId']);
        if ($code == 200) {
            if($receipt_data['Code'] != 'OK') {
                $this->result->setStatus(false);
                return false;
            } else{
                $this->result->setStatus(true)->setReceiptId($receipt_data['BizId']);
                return true;
            }
        } else {
            $this->result->setStatus(false);
            return false;
        }

    }
1329101
def send(sms_to, sms_body, **kwargs):
    
    headers = {
        "Content-type": "application/x-www-form-urlencoded",
        "User-Agent": "DBMail/%s" % get_version(),
        'Authorization': 'Basic %s' % b64encode(
            "%s:%s" % (
                settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN
            )).decode("ascii")

    }

    kwargs.update({
        'From': kwargs.pop('sms_from', settings.TWILIO_FROM),
        'To': sms_to,
        'Body': from_unicode(sms_body)
    })

    http = HTTPSConnection(kwargs.pop("api_url", "api.twilio.com"))
    http.request(
        "POST",
        "/2010-04-01/Accounts/%s/Messages.json" % settings.TWILIO_ACCOUNT_SID,
        headers=headers,
        body=urlencode(kwargs))

    response = http.getresponse()
    if response.status != 201:
        raise TwilioSmsError(response.reason)

    return loads(response.read()).get('sid')
718966
public function sendSMSResponse()
     {
        $response = new StdClass;
        $response->status = 'Sent';
        $response->message_id = $this->getValidMessageID();
        $response->sms_credits_used = 1;

        return $response;
     }
1282973
public function send_sms($apikey, $text, $mobile)
    {
        $url = "http://yunpian.com/v1/sms/send.json";
        $encoded_text = urlencode("$text");
        $mobile = urlencode("$mobile");
        $post_string = "apikey=$apikey&text=$encoded_text&mobile=$mobile";
        return $this->sock_post($url, $post_string);
    }
954198
def send_header(self, keyword, value):
        """"""
        if self.request_version != 'HTTP/0.9':
            if not hasattr(self, '_headers_buffer'):
                self._headers_buffer = []
            self._headers_buffer.append(
                ("%s: %s\r\n" % (keyword, value)).encode('latin-1', 'strict'))

        if keyword.lower() == 'connection':
            if value.lower() == 'close':
                self.close_connection = 1
            elif value.lower() == 'keep-alive':
                self.close_connection = 0
127544
protected static function _doShortcode($m)
    {
        // allow {{foo}} syntax for escaping a tag
        if ($m[1] == '{' && $m[6] == '}') {
            return substr($m[0], 1, -1);
        }

        $tag = $m[2];
        $atts = static::_parseAttributes($m[3]);
        $listeners = EventDispatcher::instance('Shortcode')
            ->eventManager()
            ->listeners($tag);

        if (!empty($listeners)) {
            $options = [
                'atts' => (array)$atts,
                'content' => null,
                'tag' => $tag
            ];

            if (isset($m[5])) {
                $options['content'] = $m[5];
            }

            $result = EventDispatcher::instance('Shortcode')
                ->triggerArray([$tag, static::cache('context')], $options)
                ->result;

            return $m[1] . $result . $m[6];
        }

        return '';
    }