changwen313
2017-05-27 10:58
采纳率: 50%
浏览 970

C# 调用微信红包接口类中第三个参数strEncoding是什么意思

C# 调用微信红包接口类中第三个参数strEncoding是什么意思,如何取得。请大神指点。
public string OpenReadWithHttps(string URL, string strPostdata, string strEncoding)
{
try
{
Encoding encoding = Encoding.UTF8;

        string cert = @"C:\zhengshu\apiclient_cert.p12";
        string password = "xxxxxx";//这里是填写的是 微信支付商户号

        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
        X509Certificate cer = new X509Certificate(cert, password);
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
        request.ClientCertificates.Add(cer);


        request.Method = "post";

        request.Accept = "text/html, application/xhtml+xml, */*";

        request.ContentType = "application/x-www-form-urlencoded";


        byte[] buffer = encoding.GetBytes(strPostdata);

        request.ContentLength = buffer.Length;

        request.GetRequestStream().Write(buffer, 0, buffer.Length);

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding(strEncoding)))
        {
            return reader.ReadToEnd();
        }
    }
    catch (Exception e)
    {

        return "";
    }

}
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题