Example #1
0
        private SMSResponse CallAPIToSendSMS(SMSRequest smsRequest)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                var json = JsonConvert.SerializeObject(smsRequest);
                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var resultString = streamReader.ReadToEnd();
                var result       = JsonConvert.DeserializeObject <SMSResponse>(resultString);

                return(result);
            }
        }
Example #2
0
        public SMSResponse SendSMS(string sdt, string noidung, string ghichu)
        {
            SMSRequest smsRequest = new SMSRequest(sdt, noidung, ghichu, this.User, this.EncodeBase64Password);

            return(CallAPIToSendSMS(smsRequest));
        }