概述
创蓝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)手机短信验证码接口的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持靠谱客。
最后
以上就是愉快鞋垫为你收集整理的C# 开发(创蓝253)手机短信验证码接口的实例的全部内容,希望文章能够帮你解决C# 开发(创蓝253)手机短信验证码接口的实例所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复