简介: 短信接口代码接入C#示例
string postString = 'spId=123&loginName=xxxxx&password=xxxx&content=测试内容&mobiles=13712345678&subPort=';//这里即为传递的参数
byte[] postData = Encoding.GBK.GetBytes(postString);//编码,尤其是汉字,事先要看下抓取网页的编码方式
string url = 'http://www.ems88.cn:8080/sms/Send.do';//接口地址
WebClient webClient = new WebClient();
webClient.Headers.Add('Content-Type', 'application/x-www-form-urlencoded');//采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可
byte[] responseData = webClient.UploadData(url, 'POST', postData);//得到返回字符流
string srcString = Encoding.UTF8.GetString(responseData);//解码