C# 开发(创蓝253)手机短信验证码接口的实例
来源:本站原创|时间:2020-01-10|栏目:C#教程|点击: 次
创蓝253: https://www.253.com/
#region 获取手机验证码(创蓝253) /// <summary> /// 获取手机验证码(创蓝253) /// </summary> /// <param name="phoneno">手机号</param> /// <returns></returns> [AllowAnonymous] public async Task<IHttpActionResult> GetPhoneCode(string phoneno) { string account = "******", password = "******", mobile = phoneno; Random rd = new Random(); int r = rd.Next(100000, 999999); string content = "【您的签名】"+"尊敬的客户:您的验证码为" + r + "!"; string postStrTpl = "un={0}&pw={1}&phone={2}&msg={3}&rd=1"; UTF8Encoding encoding = new UTF8Encoding(); byte[] postData = encoding.GetBytes(string.Format(postStrTpl, account, password, mobile, content)); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://sms.253.com/msg/send"); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = postData.Length; Stream newStream = myRequest.GetRequestStream(); newStream.Write(postData, 0, postData.Length); newStream.Flush(); newStream.Close(); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); if (myResponse.StatusCode == HttpStatusCode.OK) { return Ok(new { code = "200", res = new { msg = "短信发送成功!", data = new { code = r } } }); } else { return Ok(new { code = "400", res = new { msg = "短信发送失败!" } }); } } #endregion
以上这篇C# 开发(创蓝253)手机短信验证码接口的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我们。
您可能感兴趣的文章
- 01-10C#调用WebService实例开发
- 01-10实现ASP.NET无刷新下载并提示下载完成的开发思路
- 01-10C#开发中的垃圾回收机制简析
- 01-10C#微信开发(服务器配置)
- 01-10结合Visual C#开发环境讲解C#中事件的订阅和取消订阅
- 01-10C#开发Android百度地图手机应用程序(多地图展示)
- 01-10C#微信公众平台开发之高级群发接口
- 01-10C#微信公众平台开发之access
- 01-10C#在Unity游戏开发中进行多线程编程的方法
- 01-10C#微信开发之微信公众号标签管理功能
阅读排行
本栏相关
- 01-10C#通过反射获取当前工程中所有窗体并
- 01-10关于ASP网页无法打开的解决方案
- 01-10WinForm限制窗体不能移到屏幕外的方法
- 01-10WinForm绘制圆角的方法
- 01-10C#实现txt定位指定行完整实例
- 01-10WinForm实现仿视频播放器左下角滚动新
- 01-10C#停止线程的方法
- 01-10C#实现清空回收站的方法
- 01-10C#通过重写Panel改变边框颜色与宽度的
- 01-10C#实现读取注册表监控当前操作系统已
随机阅读
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-10C#中split用法实例总结
- 04-02jquery与jsp,用jquery
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-11ajax实现页面的局部加载
- 01-10delphi制作wav文件的方法
- 01-10SublimeText编译C开发环境设置
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 08-05DEDE织梦data目录下的sessions文件夹有什