读取接口

  public string orderapi(string hicardMerchNo, string hicardOrderNo,string merchOrderNo)
    {
        string payTime = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        string key = "验证密钥"
        string strURL = "接口地址";
        Dictionary<String, String> sParams = new Dictionary<string, string>();
        sParams.Add("version", "V001");  //版本号
        sParams.Add("hicardMerchNo", hicardMerchNo);  //汇卡商户号
        sParams.Add("merchOrderNo", merchOrderNo);  //商户订单号
        sParams.Add("hicardOrderNo", hicardOrderNo);  //汇卡订单号
        System.Net.HttpWebRequest request;
        request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
        request.Method = "POST";
        request.ContentType = "application/json;charset=UTF-8";
        string paraUrlCoded = "{\"version\":\"V001\",\"hicardMerchNo\":\"" + hicardMerchNo + "\",\"merchOrderNo\":\"" + merchOrderNo + "\",\"hicardOrderNo\":\"" + hicardOrderNo + "\",\"createTime\":\"" + payTime + "\",\"organNo\":\"机构号\",\"sign\":\"" + getsign(sParams, key, 0) + "\"}"; ;
        byte[] payload;
        payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
        request.ContentLength = payload.Length;
        Stream writer = request.GetRequestStream();
        writer.Write(payload, 0, payload.Length);
        writer.Close();
        System.Net.HttpWebResponse response;
        response = (System.Net.HttpWebResponse)request.GetResponse();
        System.IO.Stream s;
        s = response.GetResponseStream();
        string StrDate = "";
        string strValue = "";
        //取得返回的JSON
        StreamReader Reader = new StreamReader(s, Encoding.UTF8);
        while ((StrDate = Reader.ReadLine()) != null)
        {
            strValue += StrDate + "\r\n";
        }
        return strValue;
    }
    
posted @ 2017-07-04 14:20  小A爱吧  阅读(190)  评论(0编辑  收藏  举报