苹果CMS是国内优秀的开源PHP建站系统,擅长电影程序、视频程序、影视系统这一块,在主流建站系统中特色鲜明,以灵活、小巧、兼容性好、负载强等优点而深受许多站长的喜爱。小编对他还是比较了解的,今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,我们今天讲解的是v10版本,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目application\admin\view\system\configsms.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<div class= "layui-tab-content" > <div class= "layui-tab-item layui-show" > <blockquote class= "layui-elem-quote layui-quote-nm" > 提示信息:<br> 请务必按照短信接口服务商的要求做好短信签名和短信内容的设置。<br> 腾讯云短信:https: //cloud.tencent.com/product/sms<br> 腾讯云短信模板例子:<br> 尊敬的用户,您的注册会员验证码为:{1},请勿泄漏于他人!<br> 验证码为:{1},您正在绑定手机,若非本人操作,请勿泄露。<br> 验证码为:{1},您正在进行密码重置操作,如非本人操作,请忽略本短信!<br> 阿里云短信:https: //www.aliyun.com/product/sms<br> 阿里云短信模板例子:<br> 尊敬的用户,您的注册会员验证码为:${code},请勿泄漏于他人!<br> 验证码为:${code},您正在绑定手机,若非本人操作,请勿泄露。<br> 验证码为:${code},您正在进行密码重置操作,如非本人操作,请忽略本短信!<br> //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" > <select name= "sms[type]" > <option value= "" >请选择...</option> <option value= "Qcloud" { if condition= "$config['sms']['type'] eq 'Qcloud'" }selected {/ if }>腾讯云短信</option> <option value= "Aliyun" { if condition= "$config['sms']['type'] eq 'Aliyun'" }selected {/ if }>阿里云短信</option> <option value= "Smsbao" { if condition= "$config['sms']['type'] eq 'Smsbao'" }selected {/ if }>短信宝短信</option> </select> </div> <div class= "layui-form-mid layui-word-aux" ></div> </div> <div class= "layui-form-item" > <label class= "layui-form-label" >appid:</label> <div class= "layui-input-inline w400" > <input type= "text" id= "appid" name= "sms[appid]" placeholder= "" value= "{$config['sms']['appid']}" class= "layui-input" > </div> <div class= "layui-form-mid layui-word-aux" >短信宝对应短信宝账号,腾讯云对应AppId,阿里云对应KeyId</div> </div> <div class= "layui-form-item" > <label class= "layui-form-label" >appkey:</label> <div class= "layui-input-inline w400" > <input type= "text" id= "appkey" name= "sms[appkey]" placeholder= "" value= "{$config['sms']['appkey']}" class= "layui-input" > </div> <div class= "layui-form-mid layui-word-aux" >短信宝对应短信宝密码,腾讯云对应AppKey,阿里云对应KeySecret</div> </div> <div class= "layui-form-item" > <label class= "layui-form-label" >短信签名:</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= "{$config['sms']['tpl_code_reg']}" 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_bind" name= "sms[tpl_code_bind]" placeholder= "" value= "{$config['sms']['tpl_code_bind']}" 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_findpass" name= "sms[tpl_code_findpass]" placeholder= "" value= "{$config['sms']['tpl_code_findpass']}" class= "layui-input " > </div> <div class= "layui-form-mid layui-word-aux" >模板需要在服务商短信控制台中申请</div> </div> </div> </div> </div> |
2:打开项目\application\index\model 新增SmsSmsbao.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
48
|
<?php namespace app\index\model; use think\Db; class SmsSmsbao extends Base { 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' => '发生异常请重试' ]; } } } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的苹果cms_v10短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类