首页 > 代码库 > SMS106 短信验证码接口测试
SMS106 短信验证码接口测试
SMS106 短信验证码接口测试
一.什么是SMS106:
106短信通道是指仅中国移动、中国联通提供的网关短信平台,实现与客户指定号码进行短信批量发送和自定义发送的目的,即你收到的短信在手机上以106开头的短信称为106短信。 短信通道的分类国内短信通道主要分为:106通道、电信虚拟短信通道:电话区号(类似021)的、1069三网合一企业实名制通,106通道一般显示为:106通道(10657移动,联通10655,电信10659)。全网移动企业短信通通道10657,联通10655,电信10659全部能够实现上下行,全国支持,适合通知祝福类的短信,限制房地产、发票、私募基金和SP等客户信息。
二.Demo:
1.接口网:
1 private static string SendForJieKouWang(string phone) 2 { 3 4 //支持htpp get,post请求,如返回104错误,检查验证码内容是否系统提供的模板。 5 //sms.106jiekou.com/utf8/sms.aspx?account=9999&password=接口密码&mobile=13900008888&content=您的验证码是:7409。请不要把验证码泄露给其他人。如非本人操作,可不用理会!。 6 string url = "http://sms.106jiekou.com/utf8/sms.aspx"; 7 8 string account = "9999"; 9 string password = "111";10 int num = BuildCode();11 string content = "您的验证码是:" + num + "。请不要把验证码泄露给其他人。如非本人操作,可不用理会!";12 13 StringBuilder sb = new StringBuilder();14 sb.Append(url);15 sb.Append("?account=" + account);16 sb.Append("&password=" + password);17 sb.Append("&mobile=" + phone);18 sb.Append("&content=" + content);19 20 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sb.ToString());21 request.Method = "GET";22 request.Timeout = 5000;23 24 HttpWebResponse response = (HttpWebResponse)request.GetResponse();25 StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);26 string result = sr.ReadToEnd();27 sr.Close();28 code = num;29 return result;30 //直接返回状态码:成功是10031 }
2.网易云通信:
1 private static string SendForWangYiYun(string phone) 2 { 3 4 string url = "https://api.netease.im/sms/sendcode.action"; 5 string mobile = "mobile=" + phone; 6 byte[] byteArr = Encoding.UTF8.GetBytes(mobile.ToString()); 7 8 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); 9 request.Method = "POST";10 request.ContentType = "application/x-www-form-urlencoded";11 request.ContentLength = byteArr.Length;12 request.Timeout = 5000;13 14 string appKey = "43c75a269800f3fa008812481db1b031";15 string appSecret = "9c74d37ab7f1";16 string nonce = "4tgggergigwow323t231";17 string curTime = GetCurTime();18 string checkSum = HashCodeForSHA1(appSecret + nonce + curTime);19 20 request.Headers.Add("AppKey", appKey);21 request.Headers.Add("Nonce", "4tgggergigwow323t23t");22 request.Headers.Add("CurTime", curTime);23 request.Headers.Add("CheckSum", checkSum);24 25 Stream requestStream = request.GetRequestStream();26 requestStream.Write(byteArr, 0, byteArr.Length);27 requestStream.Close();28 29 HttpWebResponse response = (HttpWebResponse)request.GetResponse();30 StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);31 string result = sr.ReadToEnd();32 sr.Close();33 response.Close();34 SMSResult smsResult = JsonConvert.DeserializeObject<SMSResult>(result);35 code = Convert.ToInt32(smsResult.Obj);36 return result;37 38 //{ "code":200,"msg":"1","obj":"5996"}39 }
3.上海创明:
1 private static string SendForDuanxinWang(string phone) 2 { 3 4 string sendurl = "http://101.37.79.158/OpenPlatform/OpenApi"; 5 string action = "sendOnce"; 6 string ac = "1001@101012750001"; //用户名 7 string authkey = "1E37CA014926157DDC29A59ECA9FBD81"; //密钥 8 string cgid = "1"; //通道组编号 9 string csid = "1"; //签名编号 ,可以为空时,使用系统默认的编号10 int num = BuildCode();11 string c = "【创明短信】验证码:" + num + ", [验证码告知他人将导致帐号被盗,请勿泄露]"; // 短信的内容,不能为空12 13 StringBuilder sb = new StringBuilder();14 sb.Append("action=" + action);15 sb.Append("&ac=" + ac);16 sb.Append("&authkey=" + authkey);17 sb.Append("&cgid=" + cgid);18 sb.Append("&csid=" + csid);19 sb.Append("&m=" + phone);20 sb.Append("&c=" + c);21 22 byte[] byteArr = Encoding.GetEncoding("utf-8").GetBytes(sb.ToString());23 24 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sendurl);25 request.Method = "POST";26 request.Timeout = 5000;27 request.ContentType = "application/x-www-form-urlencoded";28 request.ContentLength = byteArr.Length;29 30 Stream requestStream = request.GetRequestStream();31 requestStream.Write(byteArr, 0, byteArr.Length);32 requestStream.Close();33 34 HttpWebResponse response = (HttpWebResponse)request.GetResponse();35 StreamReader responseStream = new StreamReader(response.GetResponseStream(), Encoding.ASCII);36 string result = responseStream.ReadToEnd();37 responseStream.Close();38 response.Close();39 code = num;40 return result;41 42 //返回xml43 //<? xml version = "1.0" ?>44 // < xml result = "1" name = "sendOnce" >45 // < Item remain = "0.100" price = "0.1" total = "1" msgid = "8450826309420610" sid = "1001" cid = "901012750001" />46 // </ xml >47 }
三.注意事项:
参数一些公司为了安全会吧一些关键的参数放入header中;
首先必须登录其官网注册,来获得自己需要的参数;
仅供参考,请勿拷贝粘贴,多动手,你的技术就会提升一大截。(拷贝你也用不了,某些隐秘参数我会乱输的,安全第一)
SMS106 短信验证码接口测试
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。