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 "";
}
}