<?
include_once 'auth.php';
include_once 'inc/utility_all.php';
include_once 'inc/utility_org.php';
include_once 'inc/utility_msg.php';
/*****/
$CUR_YEAR = date('Y');
$CUR_MONTH = date('m');
$CUR_WEEK = date('w');
$CUR_DAY = date('j');
$CUR_DATE = date('Y-m-d H:i:s');
$CUR_TIME = date('H:i:s');
$query = "select * from OFFICE_TASK where USE_FLAG='1' and TASK_CODE='sms_hadian' limit 0,1";
$cursor = exequery(TD::conn(), $query);
if (!$cursor) {
echo '-ERR ' . get_err_msg($query, $TASK_ID);
exit();
}
//18002601839
$zuotian=date("Y-m-d H:i:s",strtotime("-1 day"));
//echo $zuotian;
$query="delete from sms2 where send_time<='$zuotian'";
exequery(TD::conn(),$query);
$query = "select distinct(content) from sms2 where send_flag = 0 and SEND_TIME<='$CUR_DATE' LIMIT 0,1000";
$cursor= exequery(TD::conn(),$query);
while($ROW=mysql_fetch_array($cursor))
{
$content= $ROW["content"];
//echo $content."<br>";
$sms_id_str="";//id字符串
$phone_str="";//手机号字符串
$query1="select sms_id,phone from sms2 where send_flag = 0 and content='".$content."' limit 0,200";//每次最多提交的短信条数50*n
$cursor1=mysql_query($query1);
while($row1=mysql_fetch_array($cursor1)){
$sms_id_str.=$row1["sms_id"].",";
$phone_str.=$row1["phone"].",";
}
$sms_id_str=substr($sms_id_str,0,-1);
$phone_str=substr($phone_str,0,-1);
/**************************************/
//$SpCode="21217"; //企业编码
//$LoginName="b_bsxy";
//$Password="baie@2018";
//$SpCode="22444"; //企业编码
//$LoginName="lzx_xxjs";
//$Password="aiohYg0SAeQLC";
$SpCode="257285"; //企业编码
$LoginName="zx_lx";
$Password="zM0Hg6suxzTQGW"; //JwZtHsPP123 //zM0Hg6suxzTQGW
//https://api.ums86.com:9600/sms/Api/Send.do?SpCode=257285&LoginName=zx_lzx&Password=zM0Hg6suxzTQGW&MessageContent=你有一项编号为123456789的事务需要处理。&UserNumber=18248035486&SerialNumber=&ScheduleTime=&f=1
//$MessageContent="尊敬的张三,您本次验证码为123456,请在10分钟内使用";//$content;//
$MessageContent=$content;//
$UserNumber=$phone_str;
$url = "https://api.ums86.com:9600/sms/Api/Send.do";
// $url="http://gd.ums86.com:8899/sms/Api/Send.do";
$post_data['SpCode'] = $SpCode;
$post_data['LoginName'] = $LoginName;
$post_data['Password'] =$Password;
$post_data['MessageContent'] =$MessageContent;
$post_data['UserNumber']=$UserNumber;
$post_data['SerialNumber']='';
$post_data['ScheduleTime']='';
$post_data['ExtendAccessNum']='';
$post_data['f']='1';
$o1="";
foreach ( $post_data as $k => $v )
{
$o1.= "$k=" . urlencode( $v ). "&" ;
}
$post_data1 = substr($o1,0,-1);
$res1 =request_post($url, $post_data1);
// echo $res1;
$res1_arr=explode("&",$res1);
if($res1_arr[0]=="result=0"){
// echo "ssssuccess";
$query2 = "update sms2 set send_flag = 1 where find_in_set(sms_id,'".$sms_id_str."')";
//echo "<br>".$query2."<br><br>";
exequery(TD::conn(),$query2);
} else {
//提交失败
//逻辑代码
}
/**************************************/
}
function request_post($url = '', $param = '') {
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$curlPost = $param;
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//运行curl
curl_close($ch);
return $data;
}
update_office_task($TASK_ID, '1', date('Y-m-d H:i:s', time()));
echo '+OK';
?>
来源:CSDN
作者:hai7425
链接:https://blog.csdn.net/hai7425/article/details/103963190