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); } }
public SMSResponse SendSMS(string sdt, string noidung, string ghichu) { SMSRequest smsRequest = new SMSRequest(sdt, noidung, ghichu, this.User, this.EncodeBase64Password); return(CallAPIToSendSMS(smsRequest)); }