友点CMS系统是一款免费、开源、轻便、安全、专业建站、PC+手机+微官网+小程序+APP五站合一、一站式智能建站平台。今天小编为大家讲解一下YouDianCMS 9.1稳定版这个版本的短信插件该如何开发,短信接口使用的是我们短信宝短信群发平台,我们短信宝短信群发平台极其稳定,而且短信发送速度相当快捷,验证码和订单通知在3~5秒就能收到,用户体验非常好,注册就送测试短信。
1:打开项目:\web\themes\default\system\user-setting.html 新增短信宝接口页面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<div class= "box-content" > <table class= "boxtable" > <tr> <th nowrap= "nowrap" style= "width:20%" >短信宝</th> <td style= "width:80%" > <select name= "SMS_TYPE" > <option value= "Huyi" >短信宝</option> </select> <span style= "color:#F30; padding-left:3px;" ><a target= "_blank" href= "https://smsbao.com/reg" >还没有注册账号?立即注册</a></span> </td> </tr> <tr> <th nowrap= "nowrap" style= "width:20%" >短信宝账号</th> <td style= "width:80%" > <input type= "text" class= "textinput" style= "width:270px;" name= "SMS_ACCOUNT" value= "{$SmsAccount}" /> <span class= 'Caution' >请填写短信宝账号</span></td> </td> </tr> <tr> <th nowrap= "nowrap" style= "width:20%" >短信宝密码</th> <td style= "width:80%" > <input type= "text" class= "textinput" style= "width:270px;" name= "SMS_PASSWORD" value= "{$SmsPassword}" /> <span class= 'Caution' >请填写短信宝密码</span> </td> </tr> <tr> <th nowrap= "nowrap" style= "width:20%" >每个IP每天最多能发送几条短信</th> <td style= "width:80%" > <input type= "text" class= "textinput" style= "width:50px;" maxlength= "5" name= "SMS_IP_MAX" value= "{$SmsIpMax}" /> <span class= 'Caution' >请根据实际情况设置,默认值为:20</span> </td> </tr> <tr> <th nowrap= "nowrap" style= "width:20%" >每个手机每天最多能发送几条短信</th> <td style= "width:80%" > <input type= "text" class= "textinput" style= "width:50px;" maxlength= "5" name= "SMS_NUM_MAX" value= "{$SmsNumMax}" /> <span class= 'Caution' >请根据实际情况设置,默认值为:60</span> </td> </tr> <tr> <th nowrap= "nowrap" style= "width:20%" >剩余短信条数</th> <td style= "width:80%; padding:8px 0;" > <span id= "leftnum" style= "font-weight:bold;color:blue; margin-right:8px;" ></span> <a class= "btnSuccess btnSmall" onclick= "getLeftNum()" >点击查询</a> </td> </tr> |
3:打开项目 App\Lib\Common\YdSms.class.php 修改成短信宝发送接口
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
public function getLeftNum(){ $sendurl = $smsapi. "query?u=" .$ this ->AccountName. "&p=" .md5($ this ->AccountPassword); $result =file_get_contents($sendurl) ; $result = explode( ',' ,$result); $num = $result[1] ? $result[1] : '' ; if ($num > 0 ){ return $num; } else { return $num; } } public function sendNotifyMessage($mobile, $content){ if ( !$ this ->check($mobile) ) { $ this ->writeLog($mobile, $content, "发送失败," .$ this ->Message); return false ; } $content = $ this ->parsePlaceholder($content); $statusStr = array( "0" => "短信发送成功" , "-1" => "参数不全" , "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!" , "30" => "密码错误" , "40" => "账号不存在" , "41" => "余额不足" , "42" => "帐户已过期" , "43" => "IP地址限制" , "50" => "内容含有敏感词" ); $user = $ this ->AccountName; //短信平台帐号 $pass = md5($ this ->AccountPassword); //短信平台密码 $phone = $mobile; //要发送短信的手机号码 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl) ; $ this ->Message = $statusStr[$result]; if ( $result == 0 ){ $ this ->writeLog($mobile, $content, $statusStr[$result]); return true ; } else { $ this ->writeLog($mobile, $content, "发送失败," .$statusStr[$result]); return false ; } } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的YouDianCMSV9.1系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类