迅睿CMS內容管理框架是基于PHP7語言采用最新CodeIgniter4作為開發框架生產的網站內容管理框架,提供“電腦網站 + 手機網站 + APP 接口”一體化網站技術解決方案。她擁有強大穩定底層框架,以靈活擴展為主的開發理念,為 WEB 藝術家創造的 PHP 建站程序,堪稱 PHP 萬能建站框架。小編對他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發,我們今天講解的是V4.5.2版本,使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺的接口非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
1:打開項目:\dayrui\Fcms\Views\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
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
|
<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.gjrencai.com/reg" ?target= "_blank" >http://www.gjrencai.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> ???????????????????????? < |
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
|
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.52系統短信寶插件,點擊此鏈接?下載及查看安裝流程。
最新更新
電商類
CMS類
微信類