苹果CMS是国内优秀的开源PHP建站系统,擅长电影程序、视频程序、影视系统这一块,在主流建站系统中特色鲜明,以灵活、小巧、兼容性好、负载强等优点而深受许多站长的喜爱。小编对他还是比较了解的,今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,我们今天讲解的是v10(2023.1000.3051)版本,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:\application\common\extend\sms 新增一个Smsbao.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
47
|
<?php namespace app\common\extend\sms; class Smsbao{ public $name = '短信宝短信' ; public $ver = '1.0' ; public function submit($phone,$code,$type_flag,$type_des,$text) { if (empty($phone) || empty($code) || empty($type_flag)){ return [ 'code' =>101, 'msg' => '参数错误' ]; } $appid = $GLOBALS[ 'config' ][ 'sms' ][ 'appid' ]; $appkey = $GLOBALS[ 'config' ][ 'sms' ][ 'appkey' ]; $sign = $GLOBALS[ 'config' ][ 'sms' ][ 'sign' ]; $tpl = $GLOBALS[ 'config' ][ 'sms' ][ 'tpl_code_' .$type_flag]; $params = [ $code ]; $content = str_replace( '${code}' ,$code,$tpl); try { $statusStr = array( "0" => "短信发送成功" , "-1" => "参数不全" , "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!" , "30" => "密码错误" , "40" => "账号不存在" , "41" => "余额不足" , "42" => "帐户已过期" , "43" => "IP地址限制" , "50" => "内容含有敏感词" ); $user = $appid; //短信平台帐号 $pass = md5($appkey); //短信平台密码 $content= '【' .$sign. '】' .$content; //要发送的短信内容 $phone = $phone; //要发送短信的手机号码 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl); if ($result ==0){ return [ 'code' =>1, 'msg' => 'ok' ]; } return [ 'code' =>101, 'msg' =>$statusStr[$result]]; } catch (\Exception $e) { return [ 'code' =>102, 'msg' => '发生异常请重试' ]; } } } |
2:打开项目:application\admin\view\extend\sms 当前目录新增smsbao.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
|
<div class= "layui-tab-item" > <blockquote class= "layui-elem-quote layui-quote-nm" > 提示信息:<br> 短信宝短信:https: //www.smsbao.com/<br> 短信宝短信模板例子:<br> 尊敬的用户,您的注册会员验证码为:${code},请勿泄漏于他人!<br> 验证码为:${code},您正在绑定手机,若非本人操作,请勿泄露。<br> 验证码为:${code},您正在进行密码重置操作,如非本人操作,请忽略本短信!<br> </blockquote> <div class= "layui-form-item" > <label class= "layui-form-label" >短信宝账号:</label> <div class= "layui-input-inline w400" > <input type= "text" name= "sms[smsbao][appid]" placeholder= "" value= "{$config['sms']['smsbao']['appid']}" class= "layui-input" > </div> <div class= "layui-form-mid layui-word-aux" ></div> </div> <div class= "layui-form-item" > <label class= "layui-form-label" >短信宝密码:</label> <div class= "layui-input-inline w400" > <input type= "text" name= "sms[smsbao][appkey]" placeholder= "" value= "{$config['sms']['smsbao']['appkey']}" class= "layui-input" > </div> <div class= "layui-form-mid layui-word-aux" ></div> </div> </div> |
3:打开项目:application\admin\view\system\configsms.html 修改短信模板相关 大概39行
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
|
<div class= "layui-form-item" > <label class= "layui-form-label" >{:lang( 'admin/system/configsms/sign' )}:</label> <div class= "layui-input-inline w400" > <input type= "text" id= "sign" name= "sms[sign]" placeholder= "" value= "{$config['sms']['sign']}" class= "layui-input " > </div> <div class= "layui-form-mid layui-word-aux" ></div> </div> <div class= "layui-form-item" > <label class= "layui-form-label" >注册模板:</label> <div class= "layui-input-inline w400" > <input type= "text" id= "tpl_code_reg" name= "sms[tpl_code_reg]" placeholder= "" value= "尊敬的用户,您的注册会员验证码为:${code}" class= "layui-input " > </div> <div class= "layui-form-mid layui-word-aux" >示例:尊敬的用户,您的注册会员验证码为:${code}</div> </div> <div class= "layui-form-item" > <label class= "layui-form-label" >绑定模板:</label> <div class= "layui-input-inline w400" > <input type= "text" id= "tpl_code_bind" name= "sms[tpl_code_bind]" placeholder= "" value= "验证码为:${code},您正在绑定手机,若非本人操作,请勿泄露。" class= "layui-input " > </div> <div class= "layui-form-mid layui-word-aux" >示例:验证码为:${code},您正在绑定手机,若非本人操作,请勿泄露。</div> </div> <div class= "layui-form-item" > <label class= "layui-form-label" >找回密码:</label> <div class= "layui-input-inline w400" > <input type= "text" id= "tpl_code_findpass" name= "sms[tpl_code_findpass]" placeholder= "" value= "验证码为:${code},您正在进行密码重置操作,如非本人操作,请忽略本短信!" class= "layui-input " > </div> <div class= "layui-form-mid layui-word-aux" >示例:验证码为:${code},您正在进行密码重置操作,如非本人操作,请忽略本短信!</div> </div> |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的MaccmsV10(2023.1000.3051)系统短信宝插件,点击此链接 下载及查看安装流
最新更新
电商类
CMS类
微信类