当前位置:网站首页>PHP短信通知+语音播报自动双呼
PHP短信通知+语音播报自动双呼
2022-06-24 09:52:00 【苍穹破天】
在一些重要信息通知的场景,需要用户能收到且关注到信息,采用短信+语音通知同步推送的方式,能很好的解决这个问题。
场景一:相同内容的短信通知+语音通知同步发送
在推送短信的同时,同步推送相同内容的语音通知;用户在电话接听到通知内容后,还可通过查阅短信来确认信息内容。
适用领域:
货运司机通知、快递物流通知、物联网设备预警通知、服务器监控预警通知、重要订单信息变更通知。
通知模板示例:
【互亿无线】尊敬的***用户,您好,您的可用余额为6358条,请及时续费,自助续费请登录用户中心操作!
【互亿无线】尊敬的***用户,您好,您的账户已达您设置的最大发送量,系统已暂停发送,如需变更,请登录用户中心操作!
【**石化】您的车号***,请于***前入厂,请正确穿戴安全帽、反光马甲,听从现场人员指挥,谢谢配合!


//接口类型:无线语音通知接口。
//账户注册:请通过该地址开通账户http://user.ihuyi.com/?exClaO
//注意事项:
//(1)调试期间,请仔细阅读接口文档;
//(2)请使用APIID(查看APIID请登录用户中心->语音通知->帐户及签名设置->APIID)及 APIkey来调用接口;
//(3)该代码仅供接入无线语音通知接口参考使用,客户可根据实际需要自行编写;
//开启SESSION
session_start();
header("Content-type:text/html; charset=UTF-8");
//请求数据到短信接口,检查环境是否 开启 curl init。
function Post($curlPost,$url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
$return_str = curl_exec($curl);
curl_close($curl);
return $return_str;
}
//将 xml数据转换为数组格式。
function xml_to_array($xml){
$reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
if(preg_match_all($reg, $xml, $matches)){
$count = count($matches[0]);
for($i = 0; $i < $count; $i++){
$subxml= $matches[2][$i];
$key = $matches[1][$i];
if(preg_match( $reg, $subxml )){
$arr[$key] = xml_to_array( $subxml );
}else{
$arr[$key] = $subxml;
}
}
}
return $arr;
}
//random() 函数返回随机整数。
function random($length = 6 , $numeric = 0) {
PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
if($numeric) {
$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
} else {
$hash = '';
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghjkmnpqrstuvwxyz';
$max = strlen($chars) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
}
return $hash;
}
//短信接口地址
$target = "http://106.ihuyi.com/webservice/sms.php?method=Submit";
//获取手机号
$mobile = $_POST['mobile'];
//获取验证码
$send_code = $_POST['send_code'];
//生成的随机数
$mobile_code = random(4,1);
if(empty($mobile)){
exit('手机号码不能为空');
}
//防用户恶意请求
if(empty($_SESSION['send_code']) or $send_code!=$_SESSION['send_code']){
exit('请求超时,请刷新页面后重试');
}
$post_data = "account=用户名&password=密码&mobile=".$mobile."&content=".rawurlencode("您的验证码是:".$mobile_code."。请不要把验证码泄露给其他人。");
//查看用户名 登录用户中心->验证码通知短信>产品总览->API接口信息->APIID
//查看密码 登录用户中心->验证码通知短信>产品总览->API接口信息->APIKEY
$gets = xml_to_array(Post($post_data, $target));
if($gets['SubmitResult']['code']==2){
$_SESSION['mobile'] = $mobile;
$_SESSION['mobile_code'] = $mobile_code;
}
echo $gets['SubmitResult']['msg'];边栏推荐
- Detailed explanation of SQL Sever basic data types
- Differences among cookies, session, localstorage and sessionstorage
- Five methods of JS array summation
- 26. delete duplicates of ordered array
- Self cleaning Manual of mining Trojan horse
- What is the resource search platform and how resource search works
- Ppt drawing related, shortcut keys, aesthetics
- 图片的可视化呈现有效增强大屏吸引力
- 把腾讯搬到云上,治愈了他们的技术焦虑
- Understanding of homogeneous coordinates
猜你喜欢

图片的可视化呈现有效增强大屏吸引力

math_ Summation and derivation of proportional series & derivation of sum and difference of equal powers / difference between two nth power numbers/

Hbuilder makes hero skin lottery games

Cookie 、Session、localstorage、Sessionstorage的区别

Fashionable pop-up mode login registration window

Canvas pipe animation JS special effect

283. move zero

Moving Tencent to the cloud cured their technical anxiety

88. merge ordered arrays

24. image mosaic operation
随机推荐
喜歡就去行動
[graduation season · attacking technology Er] three turns around the tree, what branch can we rely on?
What is the bin file for? How to open the file correctly
使用Process Monitor工具监测进程对注册表和文件的操作
计组_cpu的结构和工作流程
Self cleaning Manual of mining Trojan horse
Internship experience sharing in ByteDance 𞓜 ten thousand word job guide
历史上的今天:图灵诞生日;互联网奠基人出生;Reddit 上线
Simple pricelist style code
Learn to use the kindeditor rich text editor. Click to upload a picture. The mask is too large or the white screen solution
[IEEE publication] International Conference on natural language processing and information retrieval in 2022 (ecnlpir 2022)
Canvas pipe animation JS special effect
23. opencv - image mosaic project
Disaster recovery series (II) -- enterprises' one-stop disaster recovery construction with the help of cloud platform?
Which is a good CAD drawing software? How to select good software
Suddenly I thought of the wooden house in my hometown
Rising bubble canvas breaking animation JS special effect
How to convert an array to an object, and how to convert an object to an array
突然想到老家的木屋
数组怎么转对象,对象怎么转数组