zoukankan      html  css  js  c++  java
  • 客户端调用接口

     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 }
    更多技术交流+QQ:318617848
  • 相关阅读:
    python sys.path.append
    python中的map()函数
    python中的map、filter、reduce函数
    上传文件2.0--drp203
    The import org.apache.commons.fileupload cannot be resolved
    让我会好好学习一阵子的东西
    【JSP】--Error错误页设置,声明式异常--188 drp
    【JSP】--重定向,转发--186 drp
    【JSP】--路径问题--如何去掉../,直接写绝对路径
    主备切换,双机热备,负载均衡,nginx
  • 原文地址:https://www.cnblogs.com/huyaguang/p/5863772.html
Copyright © 2011-2022 走看看