C#短信接口一代码示例
请求
string mobile = "",
con = "【微米】您的验证码是:610912,3分钟内有效。如非您本人操作,可忽略本消息。",
uid = "",
pas = "",
url = "/2/sms/send.html";
byte[] byteArray = Encoding.UTF8.GetBytes("mob=" + mobile + "&con=" + con + "&uid=" + uid + "&pas=" + pas + "&type=json");
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = byteArray.Length;
Stream newStream = webRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
StreamReader php = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string Message = php.ReadToEnd();
System.Console.Write(Message);
System.Console.Read();
/*
注意:以上参数传入时不包括“<>”符号
*/
返回结果
{ "code":0, "msg":"发送成功" }
请参考