我现在要调用移动的一个短信接口,接口类型http post的,短信内容是utf-8编码的,我这边要对短信内容进行utf-8编码,我是这样加密的,但是发过来都是乱码,是哪里不对吗?
string str = System.Web.HttpUtility.UrlEncode(msg, System.Text.Encoding.GetEncoding("utf-8"));
//this.Label1.Text = str;
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://ip:9999/smshttp?act=sendmsg&unitid=xxx&username=passwd=&msg=" + str + "&phone=&port=&sendtime=");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse HttpWResp = (HttpWebResponse)myRequest.GetResponse();
Stream myStream = HttpWResp.GetResponseStream();
StreamReader sr = new StreamReader(myStream, Encoding.UTF8);
------解决思路----------------------
对方要按照utf8格式解码才行,否则就是乱码
------解决思路----------------------
string str = System.Web.HttpUtility.UrlEncode(msg);