FineCMS是一款基于PHP+MySql+CI框架开发的高效简洁的中小型内容管理系统,面向多终端包括Pc端网页和移动端网页,支持自定义内容模型和会员模型,并且可以自定义字段,可面向中小型站点提供重量级网站建设解决方案,适用于小型站点、企业级网站、新闻内容网站等,个人站长及中小企业的首选建站系统,小编今天就以替换短信接口为例带大家进行二次开发,我们使用的短信接口是我们短信宝短信平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
下面开始进行开发,我们首先替换后台模版文件,打开项目\views\admin\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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
{template header.html} < script type = "text/javascript" > $(function() { {if $data[uid]} $.getScript("{url('admin/sms/sendsms')}&uid={$data[uid]}&key={$data[key]}¬e={$data['note']}"); {/if} }); </ script > < form action = "" method = "post" name = "myform" id = "myform" > < div class = "subnav" > < div class = "content-menu ib-a blue line-x" > < a href = "{url('admin/sms/index')}" class = "on" >< em >{lang('dr005')}</ em ></ a >< span >|</ span > < a href = "{url('admin/sms/send')}" >< em >{lang('dr006')}</ em ></ a >< span >|</ span > < a href = "http://wpa.qq.com/msgrd?v=3&uin=83961832&site=%CC%EC%EE%A3&Menu=yes" target = "_blank" >< em >定制第三方接口集成服务</ em ></ a > </ div > < div class = "bk10" ></ div > < div class = "table-list col-tab" > < div class = "contentList pad-10" > < table width = "100%" class = "table_form" > < tr class = "dr_0" > < th width = "200" >< font color = "red" >*</ font > 短信宝用户名: </ th > < td > < input class = "input-text" type = "text" name = "data[uid]" value = "{$data[uid]}" size = "25" /> < div class = "onShow" > 还没有帐号? </ div > </ td > </ tr > < tr class = "dr_0" > < th >< font color = "red" >*</ font > 短信宝密码: </ th > < td > < input class = "input-text" type = "text" name = "data[key]" value = "{$data[key]}" size = "25" /> < div class = "onShow" >< span id = "dr_sms" >...</ span ></ div > </ td > </ tr > < tr > < th >签名: </ th > < td > < input class = "input-text" type = "text" name = "data[note]" value = "{$data[note]}" size = "25" /> < div class = "onShow" >全角中括号,3-8个字符</ div > </ td > </ tr > < tr > < th style = "border:none;" > </ th > < td >< input class = "btn btn-success btn-sm" type = "submit" name = "submit" value = "{lang('submit')}" /></ td > </ tr > </ table > </ div > </ div > </ div > </ form > </ body > </ html > |
接下来我们修改查询条数的文件,打开项目\controllers\admin\Sms.php文件,新增sendsms方法,将以下代码进行覆盖:
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
|
public function sendsms() { $data = $this ->input->get(); if ( empty ( $data [ 'uid' ]) || empty ( $data [ 'key' ]) || empty ( $data [ 'note' ])) { echo "$('#dr_sms').html('<font color=red>请检查短信宝配置是否填写</font>')" ; exit ; } $statusStr = array ( '-1' => '参数不全' , '30' => '密码错误' , '40' => '帐号不存在' , '41' => '余额不足' , '43' => 'IP地址限制' , '50' => '内容含有敏感词' , '51' => '手机号码不正确' , ); $request = file_get_contents ( $url ); $ret = explode ( ',' , $request ); if ( $ret [ '1' ] > 0) { echo "$('#dr_sms').html('<font colr=red>剩余短信条数." . $ret ['1 ']."</font>' )"; exit ; } else { echo "$('#dr_sms').html('<font colr=red>" . $statusStr [ $request ]. "</font>')" ; exit ; } } |
最后我们修改发送短信的接口,打开项目\extendsions\function.php文件,我们修改fn_sendsms方法,将下面代码进行替换:
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
|
function fn_sendsms( $mobile , $content ) { if (! $mobile || ! $content ) { return FALSE; } $statusStr = array ( '0' => '发送成功' , '-1' => '参数不全' , '30' => '密码错误' , '40' => '帐号不存在' , '41' => '余额不足' , '43' => 'IP地址限制' , '50' => '内容含有敏感词' , '51' => '手机号码不正确' , ); $file = FCPATH. 'config/sms.php' ; $config = @ is_file ( $file ) ? string2array( file_get_contents ( $file )) : array (); $ret = dr_catcher_data( 'http://api.smsbao.com/sms?u=' . $config [ 'uid' ]. '&p=' .md5( $config [ 'key' ]). '&m=' . $mobile . '&c=【' . $config [ 'note' ]. '】' . $content ); if ( $ret != 0) { return false; } $result [ 'status' ] = 1; $result [ 'msg' ] = $statusStr [ $ret ]; @ file_put_contents (FCPATH. 'cache/sms.log' , date ( 'Y-m-d H:i:s' ). ' [' . $mobile . '] [' . $result [ 'msg' ]. '] (' . str_replace ( array ( chr (13), chr (10)), '' , $content ). ')' .PHP_EOL, FILE_APPEND); return $result ; } |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,我们去进行发送测试:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
另外:我们已经开发好完整的fineCMS短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类