客户端调用接口

 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}&noticeType=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 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值