コード例 #1
0
        //[ValidateRequest("fed5fd7f0b358488325d9b6216ba5845")]
        public HttpResponseMessage TwilioSMS([FromBody] SmsRequest request)
        {
            var responseString = SMSParsing.ParseSmsMessage(request);

            if (string.IsNullOrEmpty(responseString))
            {
                //TODO: Not sure how to correctly send no response, in case I don't want to respond to a command?
                //this may throw an error on Twilio's side
                return(null);
            }

            var response = new MessagingResponse();

            response.Message(responseString);

            return(Request.CreateResponse(HttpStatusCode.OK, XElement.Parse(response.ToString()), new XmlMediaTypeFormatter()));
        }
コード例 #2
0
        public HttpResponseMessage TwilioSMS([FromBody] SmsRequest request)
        {
            var responseString = SMSParsing.ParseSmsMessage(request);

            if (string.IsNullOrEmpty(responseString))
            {
                //TODO: use TwiML Bin to send no response
                //Current code throws an error on Twilio's side - a response is required
                return(null);
            }

            var response = new MessagingResponse();

            response.Message(responseString);

            return(Request.CreateResponse(HttpStatusCode.OK, XElement.Parse(response.ToString()),
                                          new XmlMediaTypeFormatter()));
        }