本文是笔记,介绍使用短信接口来发送短信通知。
1、申请短信接口
2、编写短信接口function:
其中
http://abc:0000/aaa/setting/sendSms?params=
在申请时会给出,还有请求的参数,格式,appid等。function send_message($mobile, $signName, $templateCode, $appid, $params="{}"){
global $config;
$url_api = 'http://abc:0000/aaa/setting/sendSms?params='.$params.'&mobile='.$mobile.'&signName='.$signName.'&templateCode='.$templateCode.'&appid='.$appid;
$f = fopen('mobile.log', 'a'); //可在mobile.log查看详细的发送短信链接信息
fwrite($f, $url_api."\n\n");
fclose($f);
file_get_contents($url_api);
}
3、调用
//传送参数为json格式,比如:{'days':'7'},这个是在短信中需要替换的内容,比如有效期:3天,或者有效期:7天
send_message("发送到的号码", "此处是签名,需自行替换", "此处是模板I,需自行替换", "此处为appid,需自行替换", "json格式短信中需替换的内容");
至此,可以使用自己的手机测试下短信通知功能啦