江湖家居 是一款專(zhuān)業(yè)的裝修門(mén)戶(hù)O2O系統(tǒng),PHP源碼開(kāi)源,支持二次開(kāi)發(fā),小編對(duì)于這款軟件還是比較了解的,今天小編就分享一下如何進(jìn)行二次開(kāi)發(fā),我以替換短信接口為例,一步一步教大家如何開(kāi)發(fā),使用的接口是我們短信寶短信群發(fā)平臺(tái)的短信接口,我們短信寶短信群發(fā)平臺(tái)發(fā)送速度快,非常穩(wěn)定,注冊(cè)就送測(cè)試短信,推薦大家使用。
進(jìn)行短信接口替換,首先我們需要替換后臺(tái)的顯示頁(yè)面,打開(kāi)項(xiàng)目/system/admin/view/config/sms.html,修改12~32行左右,替換代碼如下:
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
|
< div class = "page-data" > < h4 class = "tip-notice" style = "color:black;" >需要短息服務(wù)的用戶(hù)通過(guò)(< a href = "http://www.gjrencai.com" style = "color:red;" >短信寶官網(wǎng)</ a >)聯(lián)系購(gòu)買(mǎi)。</ h4 > < form action = "?system/config-sms.html" mini-form = "config-form" method = "post" > < input type = "hidden" name = "K" value = "sms" /> < table width = "100%" border = "0" cellspacing = "0" class = "table-data form" > < tr > < th >顯示錯(cuò)誤提示:</ th > < td > < label >< input type = "radio" name = "config[show_error]" <{if $config.show_error}>checked="checked"<{/if}> value="1"/>開(kāi)啟</ label > < label >< input type = "radio" name = "config[show_error]" <{if empty($config.show_error)}>checked="checked"<{/if}> value="0"/>關(guān)閉</ label > < span class = "tip-comment" >當(dāng)短息發(fā)送失敗時(shí),是否顯示相應(yīng)的提示,建議在調(diào)試時(shí)打開(kāi)</ span > </ td > </ tr > < tr > < th >帳號(hào):</ th > < td >< input type = "text" name = "config[uname]" value="<{$config.uname|default:''}>" class="input w-200"/></ td > </ tr > < tr > < th >密碼:</ th > < td >< input type = "password" name = "config[passwd]" value="<{$config.passwd|default:''}>" class="input w-200"/></ td > </ tr > < tr > < th >管理員手機(jī):</ th > < td > < input type = "text" name = "config[mobile]" value="<{$config.mobile|default:''}>" class="input w-200"/> < span class = "tip-comment" >用于接收網(wǎng)站通知,多個(gè)手機(jī)號(hào)用英文,隔開(kāi)</ span > </ td > </ tr > < tr > < th class = "clear-th-bottom" ></ th > < td class = "clear-td-bottom" colspan = "10" >< input type = "submit" class = "bt-big" value = "提交數(shù)據(jù)" /></ td > </ tr > </ table > </ form > </ div > |
后臺(tái)顯示頁(yè)面修改完成后我們需要修改短信接口的配置文件,打開(kāi)項(xiàng)目/system/schemas/config/sms.php文件,將下列代碼覆蓋進(jìn)去:
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
|
<?php /** * Copy Right Abc576.com * Each engineer has a duty to keep the code elegant * Author @shzhrui<Anhuike@gmail.com> * $Id: sms.php 2504 2013-12-25 07:00:36Z langzhong $ */ if (!defined( '__CORE_DIR' )){ exit ( "Access Denied" ); } return array ( 'uname' => array ( 'label' => '帳號(hào)' , 'field' => 'uname' , 'type' => 'text' , 'default' => '' , 'comment' => '' , 'html' => false, 'empty' => false, ), 'passwd' => array ( 'label' => '密碼' , 'field' => 'passwd' , 'type' => 'text' , 'default' => '' , 'comment' => '' , 'html' => false, 'empty' => false, ), 'mobile' => array ( 'label' => '管理員接受短信的賬號(hào)' , 'field' => 'mobile' , 'type' => 'text' , 'default' => '' , 'comment' => '' , 'html' => false, 'empty' => false, ), ); |
修改完成后我們修改,接口的發(fā)送代碼,打開(kāi)項(xiàng)目/sysytem/models/sms文件,新建一個(gè)smsbao.mdl.php文件,將以下代碼覆蓋進(jìn)去,代碼如下:
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
|
<?php Import::I( 'sms' ); class Mdl_Sms_Smsbao implements Sms_Interface { protected $_cfg = array (); public $lastmsg = '' ; public $lastcode = 1; public function __construct( $system ) { $this ->_cfg = $system ->config->get( 'sms' ); } public function send( $mobile , $content ) { $url = $this ->gateway. 'u=' . $this ->_cfg[ 'uname' ]. '&p=' .md5( $this ->_cfg[ 'passwd' ]). '&m=' . $mobile . '&c=' . $content ; $ret = file_get_contents ( $url ); if ( $ret == 0){ return true; } else { switch ( $ret ){ case 30: $error = '密碼錯(cuò)誤' ; break ; case 40: $error = '賬號(hào)不存在' ; break ; case 41: $error = '余額不足' ; break ; case 42: $error = '賬號(hào)過(guò)期' ; break ; case 43: $error = 'IP地址限制' ; break ; case 50: $error = '內(nèi)容含有敏感詞' ; break ; case 51: $error = '手機(jī)號(hào)碼不正確' ; break ; } $this ->lastcode = $ret ; $this ->lastmsg = $error ; } } } |
好了,經(jīng)過(guò)以上的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,并且免審核了,短信內(nèi)容3~5秒就可送達(dá)。
最新更新
電商類(lèi)
CMS類(lèi)
微信類(lèi)