Heim  >  Artikel  >  Backend-Entwicklung  >  SMS移动短信接口二次开发中的插入多行记录操作(含实时进度显示_PHP教程

SMS移动短信接口二次开发中的插入多行记录操作(含实时进度显示_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:38:00825Durchsuche

本来这个CP是单发的SMS接口,由于种种原因需要实现群发,每次编辑一条信息,群发网站所有会员(上万条会员记录),程序难点在从MYSQL到MSSQL不同数据库服务器间万行记录记录插入更新,并实时发送进度显示,反馈发送后的结果。

在短信发送过程中有以下几个要求:

   1)不允许出现程序超时现象; 2)自动检测手机号码的合法性;3)计算发送的进度比例;

   4)从MYSQL到MSSQL不同数据库服务器间万行记录记录插入更新,SQL语句不超负荷;

简单描述解决方法:

利用JQ 中一个AJAX脚本 递交 发送短信记录申请,程序读取申请记录,用SESSION记录下进度数据,根据每次发送的条数,返回记录中的未发送短信的手机号码,发送程序之前加手机合法性验证。AJAX接受到第一次返回记录数据,将手机号码提交给一个递归函数,再在函数中重复递交剩余的手机号码,直到进度为100%。

不知道我又没有说明白,参考代码如下:

function send_onesms(s,p,sendid){ //这个是第一个AJAX发送
if (sendid==){
$.prompt(你还没有选择要发送的短信?,{buttons:{确定:true}});
return false;
}
var totel = ;
    $(#loading).show();
    $.ajax({
     timeout: 36000,
     type: "GET",
     url: "/admincp/page.php",
     data:   "showtype=2&page="+p+&sendid=+sendid,
     beforeSend: function(){
      $.ajax({async:true,url: "/admincp/jindu.php?act=clear&rnd="+new Date().getTime(), success: function(response){$("#jindu").html(response);}, dataType: "html"});
        $(a.sendclass).html(锁定状态).removeAttr("onclick");
        $(#sid+sendid).html(发送中...).removeAttr("onclick");
     },
     success: function(msg){
       $(#i2page).val=p;
       //$(#smslist).html(unescape(msg));
       //$(#loading).hide();
       if (msg!=over){
        totel = msg;
       // setInterval(function() { $.ajax({async:true,url: "/admincp/jindu.php?rnd="+new Date().getTime(), success: function(response){$("#jindu").html(response);}, dataType: "html"}) },1000);
       }
      
      }
    });
    send_sms(s,p,sendid,totel);
    //window.clearInterval(thread);
}

function send_sms(s,p,sendid,totel){ //一个递归函数
$.ajax({
     timeout: 36000,
     dataType: "html",
     type: "POST",
     url: "/admincp/page.php?rnd="+new Date().getTime(),
     data:   "showtype=2&page="+p+&sendid=+sendid+&totel=+totel,
     success: function(response){
       if (response!=over){
         $.ajax({async:true,url: "/admincp/jindu.php?rnd="+new Date().getTime(), success: function(response){$("#jindu").html(response);}, dataType: "html"});
        setTimeout(send_sms(s,p,sendid,response),1000);
       }else{
        $.ajax({async:true,url: "/admincp/jindu.php?act=over&rnd="+new Date().getTime(), success: function(response){alert(response);}, dataType: "html"});
        $(#loading).hide();
          menu_sec2_move(p);
       }
     }

});

}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486523.htmlTechArticle本来这个CP是单发的SMS接口,由于种种原因需要实现群发,每次编辑一条信息,群发网站所有会员(上万条会员记录),程序难点在从MYSQ...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn