接口类型:互亿无线触发短信接口,支持发送验证码短信、订单通知短信等。

账户注册:请通过该地址开通账户http://sms.ihuyi.com/register.html

只能测试用:

  实现注册页面

<script type="text/javascript">
function get_mobile_code() {
$.get('Post.aspx', { mobile: jQuery.trim($('#mobile').val()) }, function (msg) {
alert(jQuery.trim(unescape(msg)));
if (msg == '提交成功') {
RemainTime();
}
});
};
var iTime = 59;
var Account;
function RemainTime() {
document.getElementById('zphone').disabled = true;
var iSecond, sSecond = "", sTime = "";
if (iTime >= 0) {
iSecond = parseInt(iTime % 60);
iMinute = parseInt(iTime / 60)
if (iSecond >= 0) {
if (iMinute > 0) {
sSecond = iMinute + "分" + iSecond + "秒";
} else {
sSecond = iSecond + "秒";
}
}
sTime = sSecond;
if (iTime == 0) {
clearTimeout(Account);
sTime = '获取手机验证码';
iTime = 59;
document.getElementById('zphone').disabled = false;
} else {
Account = setTimeout("RemainTime()", 1000);
iTime = iTime - 1;
}
} else {
sTime = '没有倒计时';
}
document.getElementById('zphone').value = sTime;
}
</script>

  

<form action="" method="post" name="formUser" onSubmit="return register();">
<table width="100%" border="0" align="left" cellpadding="5" cellspacing="3">
<tr>
<td align="right">手机<td>
<input id="mobile" name="extend_field5" type="text" size="25" class="inputBg" /><span style="color:#FF0000"> *</span>
<input id="zphone" type="button" value=" 发送手机验证码 " onClick="get_mobile_code();"></td>
</tr>
<tr>
<td align="right">验证码</td>
<td><input type="text" size="8" name="captcha" class="inputBg" /></td>
</tr>
</table>
</form>

后台代码

 public static string PostUrl = ConfigurationManager.AppSettings["WebReference.Service.PostUrl"];
protected void Page_Load(object sender, EventArgs e)
{
string account = "C23795760";//用户名是登录用户中心->验证码、通知短信->帐户及签名设置->APIID
string password = "b79bc3ff3985ea849964fb7a5fdf78ea"; //密码是请登录用户中心->验证码、通知短信->帐户及签名设置->APIKEY
string mobile = Request.QueryString["mobile"];
Random rad = new Random();
int mobile_code = rad.Next(1000, 10000);
string content = "我就是来测试的别害怕zmd:" + mobile_code + " 。请不要把验证码泄露给其他人。"; //Session["mobile"] = mobile;
//Session["mobile_code"] = mobile_code; string postStrTpl = "account={0}&password={1}&mobile={2}&content={3}"; UTF8Encoding encoding = new UTF8Encoding();
byte[] postData = encoding.GetBytes(string.Format(postStrTpl, account, password, mobile, content)); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(PostUrl);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = postData.Length; Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(postData, 0, postData.Length);
newStream.Flush();
newStream.Close(); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
if (myResponse.StatusCode == HttpStatusCode.OK)
{
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); //Response.Write(reader.ReadToEnd()); string res = reader.ReadToEnd();
int len1 = res.IndexOf("</code>");
int len2 = res.IndexOf("<code>");
string code = res.Substring((len2 + 6), (len1 - len2 - 6));
//Response.Write(code); int len3 = res.IndexOf("</msg>");
int len4 = res.IndexOf("<msg>");
string msg = res.Substring((len4 + 5), (len3 - len4 - 5));
Response.Write(msg); Response.End(); }
else
{
//访问失败
}
}

web.confg

 <appSettings>
<add key="WebReference.Service.PostUrl" value="http://106.ihuyi.cn/webservice/sms.php?method=Submit"/>
<add key="WebReference.sms" value="http://106.ihuyi.cn/webservice/sms.php?smsService"/>
</appSettings>

最新文章

  1. 让Fiddler 直接抓取java程序的方法
  2. Random
  3. 历代诗词咏宁夏注释1----常星景:&lt; 六盘&gt;
  4. Zend13.0 +XAMPP3.2.2 调试配置
  5. asp.net mvc Remote远程验证
  6. 第一个deeplearning4jproject跑起
  7. .gitignore模板
  8. NET Core个人博客
  9. HDU 1074 Doing Homework(状态压缩)
  10. GCD教程(四):完结
  11. Android 6.0 双向通话自动录音
  12. 一种使用GDI+对图片尺寸和质量的压缩方法
  13. Archlinux安装和使用技巧
  14. Python3+Selenium获取session和token供Requests使用教程
  15. JQuery插件模板
  16. Team饭来了团队作业3需求改进与系统设计
  17. iOS-APP启动页加载广告
  18. 12.19 redis缓存
  19. 史上最简单的SpringCloud教程 | 第十三篇: 断路器聚合监控(Hystrix Turbine)(Finchley版本)
  20. vs 统计有效代码行数

热门文章

  1. C++中try&amp;catch
  2. 最新vue项目添加水印
  3. 达梦产品技术支持培训-day2-DM8常用SQL
  4. springboot利用redis做缓存
  5. lua 1.0 源码分析 -- 总结
  6. 彻底根治window弹窗小广告(今日热点)
  7. 记录一次源码扩展案列——FastJson自定义反序列化ValueMutator
  8. Cypress系列(65)- 测试运行失败自动重试
  9. 发布MeteoInfo 1.2.5
  10. java9第5篇-Collection集合类的增强与优化