public ActionResult <bool> Post1(InputItem item) { ReInputItems reInput = new ReInputItems(); try { bool status = false; string url = "https://api.smartdove.net/index.php?r=smsApi/SendOneSms"; string responseString = string.Empty; string phone_number = item.MobileNumber; string content = item.MessageContent; string campaign_id = "test123"; SendMbMessage inputFlyFove = new SendMbMessage() { token = flyFoveToken, phone_number = phone_number, content = content, campaign_id = campaign_id }; string postData = string.Format("token={0}&phone_number={1}&content={2}&campaign_id={3}", flyFoveToken, phone_number, content, campaign_id); byte[] bs = Encoding.UTF8.GetBytes(postData); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = bs.Length; //using (Stream reqStream = req.GetRequestStream()) //{ // reqStream.Write(bs, 0, bs.Length); // reqStream.Close(); //} //responseString = GetResponse(req); //var aaaa = "{\"is_error\":true,\"error_code\":0,\"error_message\":\"\",\"sms_id\":\"5\",\"sms_code\":\"1\"}"; var bbb = "aasss"; //var bbb = JsonConvert.DeserializeObject(aaaa); JObject jo = (JObject)JsonConvert.DeserializeObject(responseString); string is_error = jo["is_error"].ToString(); if (!Convert.ToBoolean(is_error)) { status = true; } return(status); } catch (Exception ex) { return(false); } }
public string Verification([FromForm] string mobilNo) { string url = "https://api.smartdove.net/index.php?r=smsApi/SendOneSms"; string responseString = string.Empty; string token = "18667b283e75c2bbf4dd9ebbd4c440d1"; string phone_number = mobilNo; string content = "test smsl"; string campaign_id = "test123"; //+ DateTime.Now.ToString("yyMMddHHmmss"); string response_url = "https//:api.test.com/update.php"; //SendMbMessage inputs = new SendMbMessage(); //inputs.Token = token; //inputs.Phone_number = phone_number; //inputs.Content = content; //inputs.Campaign_id = campaign_id; //inputs.Response_url = response_url; SendMbMessage inputs2 = new SendMbMessage() { token = token, phone_number = phone_number, content = content, campaign_id = campaign_id //response_url = response_url }; string postData = "token=18667b283e75c2bbf4dd9ebbd4c440d1&phone_number=0912877857&content=test+0821&campaign_id=test1234"; string strJson2 = JsonConvert.SerializeObject(inputs2, Formatting.Indented); byte[] bs = Encoding.UTF8.GetBytes(postData); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = bs.Length; req.Timeout = 30000; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(bs, 0, bs.Length); reqStream.Close(); } //HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); //Stream stream = resp.GetResponseStream(); //using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) //{ // responseString = reader.ReadToEnd(); //} //using (StreamWriter requestWriter = new StreamWriter(wr.GetRequestStream())) //{ // requestWriter.Write(strJson2); //} //responseString = GetResponse(wr); return("aab"); }