SchoolCms是基于 ThinkPHP 的开源学校管理系统,支持文章内链、百度推送、轮播图、多条件筛选、网站地图等。小编对这款软件还是比较了解的,小编今天就以新增短信接口为例为大家讲解一下如何进行二次开发,我们使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1、执行sql语句
|
1
2
|
/**表名前缀根据自身要求进行修改**/INSERT INTO `sc_config`(`value`, `name`, `describe`, `error_tips`, `type`, `only_tag`, `upd_time`) VALUES ('', '短信宝账号', '短信宝登录账号', '请输入短信宝账号', 'home', 'common_sms_username', '1494470659'); |
2、打开项目Application\Admin\View\Default\Sms\Index.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
|
<include file="Public/Header" /><!-- right content start --><div class="content-right"> <div class="content"> <!-- table nav start --> <include file="Nav" /> <!-- table nav end --> <!-- form start --> <form class="am-form form-validation view-save" action="{{:U('Admin/Sms/Save')}}" method="POST" request-type="ajax-url" request-value="{{:U('Admin/Sms/Index', ['type'=>'sms'])}}"> <div class="am-form-group"> <label>{{$data.common_sms_username.name}}<span class="fs-12 fw-100 cr-999">({{$data.common_sms_username.describe}})</span></label> <input type="text" name="{{$data.common_sms_username.only_tag}}" placeholder="{{$data.common_sms_username.name}}" data-validation-message="{{$data.common_sms_username.error_tips}}" class="am-radius" <present name="data"> value="{{$data.common_sms_username.value}}"</present> required /> </div> <div class="am-form-group"> <label>{{$data.common_sms_apikey.name}}<span class="fs-12 fw-100 cr-999">({{$data.common_sms_apikey.describe}})</span></label> <input type="text" name="{{$data.common_sms_apikey.only_tag}}" placeholder="{{$data.common_sms_apikey.name}}" data-validation-message="{{$data.common_sms_apikey.error_tips}}" class="am-radius" <present name="data"> value="{{$data.common_sms_apikey.value}}"</present> required /> </div> <div class="am-form-group"> <label>{{$data.common_sms_sign.name}}<span class="fs-12 fw-100 cr-999">({{$data.common_sms_sign.describe}})</span></label> <input type="text" name="{{$data.common_sms_sign.only_tag}}" placeholder="{{$data.common_sms_sign.name}}" data-validation-message="{{$data.common_sms_sign.error_tips}}" class="am-radius" minlength="3" maxlength="8" <present name="data"> value="{{$data.common_sms_sign.value}}"</present> required /> </div> <div class="am-form-group"> <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'{{:L('common_form_loading_tips')}}'}">{{:L('common_operation_save')}}</button> </div> </form> <!-- form end --> </div></div><!-- right content end --> <!-- footer start --><include file="Public/Footer" /><!-- footer end --> |
3、打开项目ThinkPHP\Library\My\Sms.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
47
48
|
public function SendText($mobile, $content, $code = '') { // 是否频繁操作 if(!$this->IntervalTimeCheck()) { $this->error = L('common_prevent_harassment_error'); return false; } // 验证码替换 if(!empty($code)) { $content = str_replace('#code#', $code, $content); } // 请求发送 $user = MyC('common_sms_username'); $apikey = MyC('common_sms_apikey'); $sendurl = "http://api.smsbao.com/sms?u=".$user."&p=".$apikey."&m=".$mobile."&c=".urlencode($this->sign.$content); $res = file_get_contents($sendurl); // 错误信息 $statusStr = array( "0" => "短信发送成功", "-1" => "参数不全", "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!", "30" => "密码错误", "40" => "账号不存在", "41" => "余额不足", "42" => "帐户已过期", "43" => "IP地址限制", "50" => "内容含有敏感词" ); // 是否发送成功 if($res == 0) { // 是否存在验证码 if(!empty($code)) { $this->KindofSession($code); } return true; }else{ $this->error = $statusStr[$res]; } return false; } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的schoolCms短信宝插件,点击此链接 下载及查看安装流
最新更新
电商类
CMS类
微信类