1 public void CallBackCheck(string barcode, string ticketcount, string zybbillno) 2 {
//接口参数的定义 json格式 3 string json = "{"checkNo": "" + barcode + "","checkOrderType": "1","operateTime": "" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "","orderDetailId": "" + zybbillno + "","ticketCount": "" + ticketcount + ""}"; 4 string code = "checkNo=" + barcode;
//接口签名验证 5 string sign = MD5Encrypt(code);
//从配置文件获取接口的地址 8 string url = TwiConfigHelper.GetAppSettingValue("zybQ"); 9 //string postData = string.Format("sdk=13812095997&code=wuxi0303&phones={0}&msg={1}&resulttype=text",
//需要向接口传递的参数 10 string postData = string.Format("noticeParam={0}¬iceType=1&sign={1}", 11 json, 12 sign 13 ); 14 15 try 16 { 17 HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); 18 httpWebRequest.ContentType = "application/x-www-form-urlencoded"; 19 httpWebRequest.Method = "POST"; 20 httpWebRequest.Timeout = 20000; 21 byte[] btBodys = Encoding.UTF8.GetBytes(postData); 22 httpWebRequest.ContentLength = btBodys.Length; 23 httpWebRequest.GetRequestStream().Write(btBodys, 0, btBodys.Length); 24 HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); 25 StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()); 26 string responseContent = streamReader.ReadToEnd(); 27 httpWebResponse.Close(); 28 streamReader.Close(); 29 httpWebRequest.Abort(); 30 httpWebResponse.Close(); 31 //MessageBox.Show(responseContent); 32 } 33 catch (Exception ex) 34 { 35 //MessageBox.Show(ex.Message); 36 } 37 }