当前位置:网站首页>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'];边栏推荐
- Self cleaning Manual of mining Trojan horse
- Dedecms template file explanation and homepage label replacement
- Stack Title: exclusive time of function
- 【本周六活动】.NET Day in China
- Cause analysis of frequent crash and restart of easynvr-arm cloud terminal
- Any 与 TypeVar,让 IDE 的自动补全更好用
- Investing in a good navigation framework from the beginning of the jetpack compose tutorial will help you save a lot of migration work later
- Rising bubble canvas breaking animation JS special effect
- 程序员在技术之外,还要掌握一个技能——自我营销能力
- 服乔布斯不服库克,苹果传奇设计团队解散内幕曝光
猜你喜欢

Plant growth H5 animation JS special effect

程序员大部分时间不是写代码,而是。。。

Any and typevar make the automatic completion of IDE better

【毕业季·进击的技术er】绕树三匝,何枝可依?

math_等比数列求和推导&等幂和差推导/两个n次方数之差/

A group of skeletons flying canvas animation JS special effect

MYSQL_ Elaborate on database data types
![[graduation season · attacking technology Er] three turns around the tree, what branch can we rely on?](/img/0a/0ebfa1e5c1bea6033b538528242252.png)
[graduation season · attacking technology Er] three turns around the tree, what branch can we rely on?

Fashionable pop-up mode login registration window

Process and multithreading
随机推荐
喜欢就去行动
js数组求和的5种方法
Hbuilder makes hero skin lottery games
Svg+js drag slider round progress bar
[latest - lightweight cloud servers - hot sales] new lightweight application server optimization scheme, 1-core 2g5m time limit as low as 99 yuan / year
使用Process Monitor工具监测进程对注册表和文件的操作
Four methods of object merging and four methods of object merging in JS
“一次编写,运行各端”,高通重磅发布 AI 软件栈!
Tencent's open source project "Yinglong" has become a top-level project of Apache: the former long-term service wechat payment can hold a million billion level of data stream processing
RPM installation percona5.7.34
初识string+简单用法(一)
[Flink source code practice (I)] add a rest API to Flink
H5 video conference, camera monitoring, web streaming and live broadcast integration scheme
Cool interactive animation JS special effects implemented by p5.js
SwiftUI Swift 内功之 Swift 中的属性观察者 didSet 与 willSet
Disaster recovery series (II) -- enterprises' one-stop disaster recovery construction with the help of cloud platform?
[graduation season · attacking technology Er] three turns around the tree, what branch can we rely on?
Network monitoring: active troubleshooting becomes simple
Cook a delicious cli
Quick completion guide for manipulator (III): mechanical structure of manipulator