Handle the HTTP POST method on which alert can be sent so that the app sends an sms based on that
502681
public void doPost (HttpServletRequest request, HttpServletResponse response)
    		throws ServletException, IOException {
        String alertId = request.getParameter("alertId");
        String tel = request.getParameter("tel");
        String alertText = request.getParameter("alertText");        
        if(alertText == null || alertText.length() < 1) {
	        // Get the content of the request as the text to parse
	        byte[] content = new byte[request.getContentLength()];
	        request.getInputStream().read(content,0, request.getContentLength());        
	        alertText = new String(content); 	        
        }
        if(logger.isInfoEnabled()) {
        	logger.info("Got an alert : \n alertID : " + alertId + " \n tel : " + tel + " \n text : " +alertText);
        }
        // 
        try {
        	Properties jndiProps = new Properties();			
			Context initCtx = new InitialContext(jndiProps);
			// Commented out since the preferred way is through SMS Servlets
//        	SleeConnectionFactory factory = (SleeConnectionFactory) initCtx.lookup("java:/MobicentsConnectionFactory");
//        	
//			SleeConnection conn1 = factory.getConnection();
//			ExternalActivityHandle handle = conn1.createActivityHandle();
//
//			EventTypeID requestType = conn1.getEventTypeID(
//					EVENT_TYPE,
//					"org.mobicents", "1.0");
//			SmsAlertingCustomEvent smsAlertingCustomEvent = new SmsAlertingCustomEvent(alertId, tel, alertText);
//			
//			conn1.fireEvent(smsAlertingCustomEvent, requestType, handle, null);
//			conn1.close();
		} catch (Exception e) {
			logger.error("unexpected exception while firing the event " + EVENT_TYPE + " into jslee", e);
		}	
        
        sendHttpResponse(response, OK_BODY);
    }
1199981
function Request(method, url) {
  var self = this;
  this._query = this._query || [];
  this.method = method;
  this.url = url;
  this.header = {}; // preserves header name case
  this._header = {}; // coerces header names to lowercase
  this.on('end', function(){
    var err = null;
    var res = null;

    try {
      res = new Response(self);
    } catch(e) {
      err = new Error('Parser is unable to parse the response');
      err.parse = true;
      err.original = e;
      // issue #675: return the raw response if the response parsing fails
      err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;
      // issue #876: return the http status code if the response parsing fails
      err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;
      return self.callback(err);
    }

    self.emit('response', res);

    var new_err;
    try {
      if (res.status < 200 || res.status >= 300) {
        new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
        new_err.original = err;
        new_err.response = res;
        new_err.status = res.status;
      }
    } catch(e) {
      new_err = e; // #985 touching res may cause INVALID_STATE_ERR on old Android
    }

    // #1000 don't catch errors from the callback to avoid double calling it
    if (new_err) {
      self.callback(new_err, res);
    } else {
      self.callback(null, res);
    }
  });
}
1063872
def method_missing(method, *args)
      if method.to_s.match /subscription/
        if args.size == 2
          @subscriptions.send method, args[0], args[1]
        else
          @subscriptions.send method, args[0]
        end
      else
        if method == :delivery_status || method == :retrieve_sms || method == :search_sms
          @reporting.send method, args[0]
        else
          raise RuntimeError, 'Unknown method'
        end
      end
    end
747507
def api_post(message, url, name, http_data=None, auth=None):
    
    try:
        import requests
    except ImportError:
        print('requests is required to do api post.', file=sys.stderr)
        sys.exit(1)

    data = {name : message}
    if http_data:
        for var in http_data:
            key, value = var.split('=')
            data[key] = value

    response = requests.post(
        url,
        data=data,
        auth=auth
    )

    if response.status_code != 200:
        raise RuntimeError('Unable to post data')
566351
function sendClientAlertMessage(ws, alert) {
  var msg = JSON.stringify({
    custom: {
      alert: alert
    }
  });
  ws.write(msg);
}
646480
function send(message, callback) {
  const suppliedCallback = callback || function () {};
  if (!message) {
    return suppliedCallback(new Error('No message'));
  }
  const requestParams = {
    url: this.webhook,
    body: extend(this.options, { text: message }),
    json: true
  };
  return request.post(requestParams, function (err, res, body) {
    if (err || body !== 'ok') {
      return suppliedCallback(err || new Error(body));
    }
    return suppliedCallback(null, body);
  });
}
354794
function SmsRequest (smsc, appcb, smscmd) {
    var self=this; // nodejs is still a bad language
    this.debug = smsc.debug;
    this.retry = 0;

    // this method is called when DelById is executed
    function DelByIdCB (err) {
        self.Debug (9,"DelCallBack err=%s", err);
    }

    // this method is called by MySql when sms.GetFrom return
    function CheckDevAckCB(err, results) {
        self.retry ++; // retry counter for ACK
        self.Debug (6, "CheckDevAckCB Phone=%s Retry=%d/%d Result=%j", smscmd.phone, self.retry, smsc.opts.retry, results);
        // ack no received
        if (results.length === 0) {
            if (self.retry <= smsc.opts.retry) {
                setTimeout (function() {CheckDevAck ();}, smsc.opts.delay);
            } else {
                self.Debug (7, "CheckDevAckCB Ack Abandoned MaxRetry=%s", smsc.opts.retry);
                appcb ({status: -2, smsid: smscmd.id});
            }
        } else {
            // we may have more than one responses for a given command
            for (var slot in results) {
                var ack =
                { status: 2
                    , smsid: smscmd.id
                    , phone: smscmd.phone
                    , ack: results[slot].TextDecoded
                };
                // ACK received, delete it from inbox and send it to application
                self.Debug (6, "CheckDevAckCB Ack Received %j", ack);
                smsc.DelById (DelByIdCB, results[slot].Id);
                appcb({status: 2, smsid: smscmd.id, msg: ack});
            }
            appcb({status: 0});
        }
    }

    // this method check sms inbox table for OK ack from device
    function CheckDevAck() {
        self.Debug (3,"Waiting Acknowledgment Response %d/%d", self.retry, smsc.opts.retry);
        smsc.GetFrom (CheckDevAckCB, smscmd.phone)
    }

    // this function is call when MySql checked outbox
    function CheckOutboxCB(err, results) {
        var result = results[0];  // Query result is alway an array of response even when unique
        self.retry ++; // update retry counter
        // if message is still in queue retry
        self.Debug (6,"CheckOutboxCB Phone=%s Result=%j Retry=%d/%d", smscmd.phone, result, self.retry, smsc.opts.retry);
        if (result !== undefined) {
            // message is still in queue loop one more time
            if (self.retry <= smsc.opts.retry) {
                setTimeout (function() {CheckOutbox (result.ID);}, smsc.opts.delay);
            } else {
                // notify appcb that SMS failed and was deleted
                self.Debug (6,"CheckOutboxCB Fail SqlId=%s SMS=%j", result.ID, smscmd);
                smsc.DelById (DelByIdCB, result.ID);
                appcb ({status: -1, smsid: smscmd.id});

            }
        } else {
            // le message à été expédié
            self.Debug (6,"CheckOutboxCB OK SMS=%j", smscmd);
            appcb ({status: 1, smsid: smscmd.id});

            // if an acknowledgement is asked loop until we get it.
            if (smscmd.ack) {
                self.retry = 0; // reset retry counter for ack
                setTimeout (function() {CheckDevAck (smscmd);}, smsc.opts.delay);
            } else {
                  appcb ({status: 0});
            }
        }
    }

    // this function loop until SMS is effectively sent
    function CheckOutbox (insertId) {
        self.Debug (3,"Waiting Sent Confirmation  %d/%d", self.retry, smsc.opts.retry);
        smsc.CheckById (CheckOutboxCB, insertId)
    }

    // this function is called when MySql inserted SMS in outbox
    function SendToCB (err, result) {
        // check if sms was sent from output table
        self.Debug (7,"SendToCB SMS=%j result=%j err=%j", smscmd, result, err);
        if (err) {
            self.Debug (1, "Insert in MySql outbox refused %s", err);
            appcb ({status: -1, id: smscmd.id, error: err});
        } else {
            setTimeout (function() {CheckOutbox (result.insertId);}, smsc.opts.delay);
        }
    }
    this.Debug (2,"Queuing Phone=%s SMS=%s", smscmd.phone, smscmd.msg);
    if (smscmd.phone == undefined ||  smscmd.msg == undefined) {
        SendToCB ({status: -1, info: 'Invalid SMS [missing phone and/or message'});
        return;
    }
    smsc.SendTo (SendToCB, smscmd);
}
210730
def send(phone_number, message, wait_for_user_anwser=false, slow_multi_sms=false)
      body = {
        numero_destino: phone_number,
        mensagem: message,
        resposta_usuario: wait_for_user_anwser,
        multi_sms: slow_multi_sms
      }

      puts self.class.post('/sms', {body: body.to_json})
    end
1215251
async def call(self,
                   method: Text,
                   _ignore: Set[Text] = None,
                   **params: Any):
        

        logger.debug('Calling Telegram %s(%s)', method, params)

        url = self.make_url(method)

        headers = {
            'content-type': 'application/json',
        }

        post = self.session.post(
            url,
            data=ujson.dumps(params),
            headers=headers,
        )

        async with post as r:
            out = await self._handle_telegram_response(r, _ignore)
            logger.debug('Telegram replied: %s', out)
            return out
501458
function Sms(opts) {

  if (!(this instanceof Sms)) {
    return new Sms(opts);
  }

  // Ensure opts is an object
  opts = opts || {};
  
  // API user 
  this.user = opts.user || null;
  
  // API password
  this.pass = opts.pass || null;
  
  // Message
  this.message = opts.message || null;    
}
1048043
def send(self, message):
        
        body = {
            'notificationType': self._notification_type,
            'priority': self._priority,
            'isOrganization': self._is_organization,
            'message': message,
        }

        if self._recipients:
            body['recipients'] = self._recipients

        self._tcex.log.debug('notification body: {}'.format(json.dumps(body)))

        # create our tcex resource
        resource = resource = self._tcex.resource('Notification')
        resource.http_method = 'POST'
        resource.body = json.dumps(body)

        results = resource.request()  # do the request
        if results.get('response').status_code == 200:
            # everything worked
            response = results.get('response').json()
        elif results.get('response').status_code == 400:
            # failed..but known... user doesn't exist
            # just return and let calling app handle it
            err = 'Failed to send notification ({})'.format(results.get('response').text)
            self._tcex.log.error(err)
            response = results.get('response').json()
        else:
            # somekind of unknown error...raise
            err = 'Failed to send notification ({})'.format(results.get('response').text)
            self._tcex.log.error(err)
            raise RuntimeError(err)
        return response
178970
def message(from, to, body, callback_url=nil)
      callback = callback_url ? {:StatusCallback => callback_url} : {}
      Twilio.post("/SMS/Messages", :body => {:From => from, :To => to, :Body => body}.merge(callback))
    end
963225
def notify(title, message, key, event=None, retcode=None):
    

    data = {
        'title': title if len(title) <= 20 else title[:19] + u'\u2026',
        'msg': message,
        'key': key
    }

    if event:
        data['event'] = event

    headers = {'User-Agent': USER_AGENT}

    endpoint = "https://api.simplepush.io"

    resp = requests.post(endpoint + '/send', data=data, headers=headers)

    resp.raise_for_status()
972076
def on_message(self, sender, content):
        
        try:
            message = json.loads(content)

        except (ValueError, TypeError) as ex:
            logging.error("Not a valid JSON string: %s", ex)
            return

        try:
            # Check the replied message
            reply_uid = message['reply-to']
            reply_level = message['reply-level']

        except KeyError:
            # Got a new message
            logging.info("Got message %s from %s", message['content'], sender)

            # Notify listeners
            self.__pool.enqueue(self._notify_listeners, sender, message)

        else:
            # Got a reply
            try:
                level, callback = self.__callbacks[reply_uid]

            except KeyError:
                # Nobody to callback...
                pass

            else:
                if level == reply_level:
                    # Match
                    try:
                        callback(sender, message['payload'])
                    except Exception as ex:
                        logging.exception("Error notifying sender: %s", ex)
157366
def send(self, fail_silently=False):
        
        if not self.to:
            # Don't bother creating the connection if there's nobody to send to
            return 0
        res = self.get_connection(fail_silently).send_messages([self])
        sms_post_send.send(sender=self, to=self.to, from_phone=self.from_phone, body=self.body)
        return res
1055972
def send_notification(self, method, params):
        
        msg = self._encoder.create_notification(method, params)
        self._send_message(msg)
1311968
function BatchResponseCB (data) {
    switch (data.status ) {
        case -1: console.log (" SMS -%d- Fail to Send SMS", data.smsid);
            break;
        case -2: console.log (" SMS -%d- Timeout waiting acknowledgement", data.smsid);
            break;
        case 1: console.log (" SMS -%d- Message Sent", data.smsid);
            break;
        case 2: console.log (" SMS -%d- Acknowledgement=[%s]", data.smsid, data.msg.ack);
            break;
        default:
    }
    // quit except if we wait for ack [leave some time to DB to close operation]
    if (data.status === 0) {
        console.log ('Last SMS from batch processed');
        setTimeout(process.exit, 1000);
    }
}