迅睿CMS内容管理框架基于迅睿框架采用PHP7技术+CodeIgniter4作为系统核心部件,由系统框架+应用插件快速组建Web应用。小编对他还是比较了解的,今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,我们今天讲解的是V4.2.3版本,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1.打开项目:\admin\templates\plus\sms.htm 新增短信宝页面代码
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<script type= "text/javascript" > $( function () { { if $data .uid && ! $data .third} $.ajax({ type: "GET" , dataType: "json" , url: "{dr_url('api/sms_info')}&uid={$data.uid}&key={$data.key}" , success: function (json) { eval (json.code); }, error: function (HttpRequest, ajaxOptions, thrownError) { alert( '网络异常' ); } }); {/ if } { if $data .type == 0} $( '.dr_0' ).show();$( '.dr_1' ).hide();$( '.dr_2' ).hide(); { else if $data .type == 1} $( '.dr_1' ).show();$( '.dr_0' ).hide();$( '.dr_2' ).hide(); { else if $data .type == 2} $( '.dr_2' ).show();$( '.dr_1' ).hide();$( '.dr_0' ).hide(); {/ if } }); </script> <form action= "" class = "form-horizontal" method= "post" name= "myform" id= "myform" > {dr_form_hidden()} <div class = "portlet bordered light myfbody" > <div class = "portlet-title tabbable-line" > <ul class = "nav nav-tabs" style= "float:left;" > <li class = "{if $page==0}active{/if}" > <a href= "#tab_0" data-toggle= "tab" onclick= "$('#dr_page').val('0')" > <i class = "fa fa-cog" ></i> {dr_lang( '短信参数' )} </a> </li> </ul> </div> <div class = "portlet-body" > <div class = "tab-content" > <div class = "tab-pane {if $page==0}active{/if}" id= "tab_0" > <div class = "form-body" > <div class = "form-group" > <label class = "col-md-2 control-label" style= "padding-top: 10px;" >{dr_lang( '接口类型' )}</label> <div class = "col-md-9" > <div class = "mt-radio-inline" > <label class = "mt-radio mt-radio-outline" ><input name= "aa" type= "radio" value= "0" onclick= "$('.dr_0').show();$('.dr_1').hide();$('.dr_2').hide()" { if ! $data .third}checked= "checked" {/ if } /> {dr_lang( '官方接口' )} <span></span></label> <label class = "mt-radio mt-radio-outline" ><input name= "aa" type= "radio" value= "1" onclick= "$('.dr_1').show();$('.dr_0').hide();$('.dr_2').hide()" { if $data .third}checked= "checked" {/ if } /> {dr_lang( '第三方接口' )} <span></span></label> <label class = "mt-radio mt-radio-outline" ><input name= "aa" type= "radio" value= "2" onclick= "$('.dr_2').show();$('.dr_0').hide();$('.dr_1').hide();" { if $data .third}checked= "checked" {/ if } /> {dr_lang( '短信宝接口' )} <span></span></label> </div> </div> </div> <div class = "form-group dr_0" > <label class = "col-md-2 control-label" >官方SMS Uid</label> <div class = "col-md-9" > <label><input class = "form-control" type= "text" name= "data[uid]" value= "{$data.uid}" ></label> </div> </div> <div class = "form-group dr_0" > <label class = "col-md-2 control-label" >官方SMS Key</label> <div class = "col-md-9" > <input class = "form-control" type= "text" name= "data[key]" value= "{$data.key}" > </div> </div> { if $data .uid && ! $data .third} <div class = "form-group dr_0" > <label class = "col-md-2 control-label" >{dr_lang( '剩余短信' )}</label> <div class = "col-md-9" > <div class = "form-control-static" id= "dr_sms" >....</div> </div> </div> {/ if } <div class = "form-group dr_1" > <label class = "col-md-2 control-label" >{dr_lang( '自定义参数' )}</label> <div class = "col-md-9" > <textarea class = "form-control" style= "height:120px" name= "data[third]" />{ $data .third}</textarea> </div> </div> <div class = "form-group dr_1" > <label class = "col-md-2 control-label" >{dr_lang( '测试手机号' )}</label> <div class = "col-md-9" > <label><input class = "form-control" type= "text" name= "data[mobile]" value= "{$data.mobile}" ></label> <span class = "help-block" >单击测试按钮会将验证码发送到此手机</span> </div> </div> <div class = "form-group dr_2" > <label class = "col-md-2 control-label" >{dr_lang( '申请地址' )}:</label> <div class = "col-md-9" > <div class = "form-control-static" ><label><a href= "http://www.smsbao.com/reg" target= "_blank" >http://www.smsbao.com/reg</a></label></div> </div> </div> <div class = "form-group dr_2" > <label class = "col-md-2 control-label" >{dr_lang( '短信宝账号' )}</label> <div class = "col-md-9" > <label><input class = "form-control" type= "text" name= "data[smsbaouser]" value= "{$data.smsbaouser}" ></label> </div> </div> <div class = "form-group dr_2" > <label class = "col-md-2 control-label" >{dr_lang( '短信宝密码' )}</label> <div class = "col-md-9" > <label><input class = "form-control" type= "text" name= "data[smsbaopass]" value= "{$data.smsbaopass}" ></label> </div> </div> <div class = "form-group dr_2" > <label class = "col-md-2 control-label" >{dr_lang( '短信宝签名' )}</label> <div class = "col-md-9" > <label><input class = "form-control" type= "text" name= "data[smsbaosing]" value= "{$data.smsbaosing}" ></label> </div> </div> <div class = "form-group dr_0" > <label class = "col-md-2 control-label" >{dr_lang( '短信签名' )}</label> <div class = "col-md-9" > <label><input class = "form-control" type= "text" name= "data[note]" value= "{$data.note}" ></label> <span class = "help-block" >保持在10个字符以内</span> </div> </div> |
2.打开项目:\dayrui\Fcms\Model\Member.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
49
50
51
52
53
54
55
56
|
public function sendsms_text( $mobile , $content , $type = 'text' ) { if (! $mobile || ! $content ) { return dr_return_data(0, dr_lang( '手机号码或内容不能为空' )); } $file = WRITEPATH. 'config/sms.php' ; if (! is_file ( $file )) { log_message( 'error' , '短信接口配置文件不存在' ); return dr_return_data(0, dr_lang( '接口配置文件不存在' )); } $config = require_once $file ; if ( $config [ 'third' ]) { if ( is_file (WEBPATH. 'config/mysms.php' )) { require_once WEBPATH. 'config/mysms.php' ; } $method = 'my_sendsms_' . $type ; if (function_exists( $method )) { return call_user_func_array( $method , [ $mobile , $content , $config [ 'third' ], ]); } else { $error = dr_lang( '你没有定义第三方短信接口: ' . $method ); @ file_put_contents (WRITEPATH. 'sms_log.php' , date ( 'Y-m-d H:i:s' ). ' [' . $mobile . '] [' . $error . '] (' . str_replace ( array ( chr (13), chr (10)), '' , $content ). ')' .PHP_EOL, FILE_APPEND); return dr_return_data(0, $error ); } } else { $content = $type == 'code' ? dr_lang( '您的本次验证码是: %s' , $content ) : $content ; $content = '【' . $config [ 'smsbaosing' ]. '】' . $content ; $user = $config [ 'smsbaouser' ]; //短信平台帐号 $pass = md5( $config [ 'smsbaopass' ]); //短信平台密码 $phone = $mobile ; //要发送短信的手机号码 $url = $smsapi . "sms?u=" . $user . "&p=" . $pass . "&m=" . $phone . "&c=" .urlencode( $content ); $result = dr_catcher_data( $url ); if ( $result != 0) { log_message( 'error' , '访问官方云短信服务器失败' ); return dr_return_data(0, dr_lang( '访问官方云短信服务器失败' )); } else { $result = "{\"code\":1, \"data\":\"发送成功\", \"msg\":\"发送成功\"}" ; } $result = json_decode( $result , true); } @ file_put_contents (WRITEPATH. 'sms_log.php' , 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秒就可送达。
另外:我们已经开发好完整的迅睿CMSV4.2.3系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类