EyouCms是基于TP5.0框架為核心開發(fā)的免費(fèi)+開源的企業(yè)內(nèi)容管理系統(tǒng),專注企業(yè)建站用戶需求提供海量各行業(yè)模板。小編對(duì)這款系統(tǒng)還比較了解,今天就以替換短信接口為例為大家講解一下如何進(jìn)行二次開發(fā),使用的短信接口是我們短信寶短信群發(fā)平頭的短信接口,我們短信寶短信群發(fā)平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用。
1:打開項(xiàng)目:\application\admin\template\system\sms.htm 修改大概35行代碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<dl class= "row" id= "sms_appkey_1" style= "display: {if condition=" !isset($sms.sms_type) || $sms.sms_type eq 1 "} block{else /}none{/if};" > <dt class= "tit" > <em>*</em> <label for = "sms_appkey" >短信寶賬號(hào)</label> </dt> <dd class= "opt" > <input id= "sms_appkey" name= "sms_appkey" value= "{$sms.sms_appkey|default=''}" class= "input-txt" type= "text" /> <p class= "notic" >短信寶賬號(hào)</p> </dd> </dl> <dl class= "row" id= "sms_secretkey_1" style= "display: {if condition=" !isset($sms.sms_type) || $sms.sms_type eq 1 "} block{else /}none{/if};" > <dt class= "tit" > <em>*</em> <label for = "sms_secretkey" >短信寶密碼</label> </dt> <dd class= "opt" > <input id= "sms_secretkey" name= "sms_secretkey" value= "{$sms.sms_secretkey|default=''}" class= "input-txt" type= "text" /> <p class= "notic" >短信寶密碼</p> </dd> </dl> |
2:打開項(xiàng)目:\application\admin\template\system\sms_tpl.htm 修改大概58行代碼
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
|
<div class= "hDiv" > <div class= "hDivBox" > <table cellspacing= "0" cellpadding= "0" style= "width: 100%" > <thead> <tr> <th abbr= "article_title" axis= "col3" class= "w100" > <div class= "text-l10" >模板類型</div> </th> <th abbr= "article_title" axis= "col3" class= "w230" > <div class= "text-l10" >簽名名稱</div> </th> <!--<th abbr= "article_title" axis= "col3" class= "w230" >--> <!-- <div class= "" >模板CODE</div>--> <!--</th>--> <th abbr= "article_title" axis= "col3" class= "" > <div class= "text-l10" >模板內(nèi)容</div> </th> <th abbr= "article_time" axis= "col6" class= "w50" > <div class= "tc" >啟用</div> </th> <th abbr= "article_time" axis= "col6" class= "w100" > <div class= "tc" >更新時(shí)間</div> </th> </tr> </thead> </table> </div> </div> |
3:打開項(xiàng)目:\application\admin\template\system\notify.htm 修改代碼42行
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<div class= "plug-item-content" > <div class= "plug-item-top" > <div class= "plug-img" > <a href= "{:url('System/sms')}" ><img src= "__SKIN__/images/sms.png?v={$version}" ></a> </div> <div class= "plug-text" > <div class= "plug-text-title" > <a href= "{:url('System/sms')}" >云短信 </a> </div> <div class= "plug-text-versions" > <span>系統(tǒng)內(nèi)置</span> </div> <!-- <div class= "plug-text-des" >暫無(wú)描述</div> --> </div> </div> <div class= "plug-item-bottm" > <a href= "{:url('System/sms')}" >配置</a> </div> </div> |
4:打開項(xiàng)目:\application\admin\controller\System.php 新增smsSave方法
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
|
public function smsSave() { $inc_type = 'sms' ; if (IS_POST) { $param = input( 'post.' ); if (!isset($param[ 'sms_type' ])) $param[ 'sms_type' ] = 1; if ($param[ 'sms_type' ] == 1) { unset($param[ 'sms_appkey_tx' ]); unset($param[ 'sms_appid_tx' ]); } else { unset($param[ 'sms_appkey' ]); unset($param[ 'sms_secretkey' ]); } // $param['sms_shop_order_pay'] = !empty($param['sms_shop_order_pay']) ? 1 : 0; // $param['sms_shop_order_send'] = !empty($param['sms_shop_order_send']) ? 1 : 0; /*多語(yǔ)言*/ if (is_language()) { $langRow = \think\Db::name( 'language' )->order( 'id asc' ) ->cache( true , EYOUCMS_CACHE_TIME, 'language' ) ->select(); foreach ($langRow as $key => $val) { tpCache($inc_type, $param, $val[ 'mark' ]); } } else { tpCache($inc_type, $param); } /*--end*/ $ this ->success( '操作成功' , url( 'System/sms' )); } $sms = tpCache( 'sms' ); if (!isset($sms[ 'sms_type' ])) { $sms[ 'sms_type' ] = 1; tpCache( 'sms' , array( 'sms_type' =>1)); } $ this ->assign( 'sms' , $sms); return $ this ->fetch(); } |
5:打開項(xiàng)目:\application\common\logic\SmsLogic.php 修改167行代碼
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
|
private function sendSmsBao($mobile, $smsSign, $smsParam, $templateCode) { $statusStr = array( "0" => "短信發(fā)送成功" , "-1" => "參數(shù)不全" , "-2" => "服務(wù)器空間不支持,請(qǐng)確認(rèn)支持curl或者fsocket,聯(lián)系您的空間商解決或者更換空間!" , "30" => "密碼錯(cuò)誤" , "40" => "賬號(hào)不存在" , "41" => "余額不足" , "42" => "帳戶已過(guò)期" , "43" => "IP地址限制" , "50" => "內(nèi)容含有敏感詞" ); $user = $ this ->config[ 'sms_appkey' ]; //短信平臺(tái)帳號(hào) $pass = md5($ this ->config[ 'sms_secretkey' ]); //短信平臺(tái)密碼 $content= '【' .$smsSign. '】' .$templateCode; //要發(fā)送的短信內(nèi)容 $phone = $mobile; //要發(fā)送短信的手機(jī)號(hào)碼 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl) ; //短信發(fā)送成功返回True,失敗返回false if ($result == '0' ) { return array( 'status' => 1, 'msg' => '發(fā)送成功' ); } else { return array( 'status' => -1, 'msg' => '短信發(fā)送失敗' ); } } |
好了,經(jīng)過(guò)以上的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。我們進(jìn)行測(cè)試發(fā)送。
報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開發(fā)好完整的Eyoucms_v1.6.8系統(tǒng)短信寶插件,點(diǎn)擊此鏈接?下載及查看安裝流程。
最新更新
電商類
CMS類
微信類