EyouCms是基于TP5.0框架为核心开发的免费+开源的企业内容管理系统,专注企业建站用户需求提供海量各行业模板。小编对这款系统还比较了解,今天就以替换短信接口为例为大家讲解一下如何进行二次开发,使用的短信接口是我们短信宝短信群发平头的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:\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" >短信宝账号</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" >短信宝账号</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:打开项目:\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" >模板内容</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" >更新时间</div> </th> </tr> </thead> </table> </div> </div> |
3:打开项目:\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>系统内置</span> </div> <!-- <div class= "plug-text-des" >暂无描述</div> --> </div> </div> <div class= "plug-item-bottm" > <a href= "{:url('System/sms')}" >配置</a> </div> </div> |
4:打开项目:\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; /*多语言*/ 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:打开项目:\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" => "短信发送成功" , "-1" => "参数不全" , "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!" , "30" => "密码错误" , "40" => "账号不存在" , "41" => "余额不足" , "42" => "帐户已过期" , "43" => "IP地址限制" , "50" => "内容含有敏感词" ); $user = $ this ->config[ 'sms_appkey' ]; //短信平台帐号 $pass = md5($ this ->config[ 'sms_secretkey' ]); //短信平台密码 $content= '【' .$smsSign. '】' .$templateCode; //要发送的短信内容 $phone = $mobile; //要发送短信的手机号码 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl) ; //短信发送成功返回True,失败返回false if ($result == '0' ) { return array( 'status' => 1, 'msg' => '发送成功' ); } else { return array( 'status' => -1, 'msg' => '短信发送失败' ); } } |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。我们进行测试发送。
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的Eyoucms_v1.6.8系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类