DSMALL系統是基于THinkPHP開發的一款開源的B2B2C電子商務系統,因為是THinkPHP開發所以二次開發比較方便,小編對于這套程序還是比較了解的,今天小編就以替換短信接口為例,為大家講解一下如何進行二次開發,我們今天講解的是20171202版本,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
第一步,我們去替換后臺顯示界面,打開項目\application\admin\view\message\mobile.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
|
{include file="public/header" /} < div id = "append_parent" ></ div > < div id = "ajaxwaitid" ></ div > < div class = "page" > < div class = "fixed-bar" > < div class = "item-title" > < div class = "subject" > < h3 >郵箱短信</ h3 > < h5 ></ h5 > </ div > {include file="public/admin_items" /} </ div > </ div > < form method = "post" > < div class = "ncap-form-default" > < dl > < dt >短信寶用戶名</ dt > < dd > < input type = "text" name = "mobile_username" id = "mobile_username" value = "{$list_config.mobile_username}" class = "w200" /> </ dd > </ dl > < dl > < dt >短信寶密碼</ dt > < dd > < input type = "text" name = "mobile_pwd" id = "mobile_pwd" value = "{$list_config.mobile_pwd}" class = "w200" /> </ dd > </ dl > < dl > < dt >短信簽名</ dt > < dd > < input type = "text" name = "mobile_signature" id = "mobile_signature" value = "{$list_config.mobile_signature}" class = "w200" /> </ dd > </ dl > < dl > < dt ></ dt > < dd > < input class = "btn" type = "submit" value = "提交" /> </ dd > </ dl > </ div > </ form > </ div > |
第二步,我們去修改短信接口類,打開項目\extend\sendmsg\Sms.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
|
<?php /** * 手機短信類 */ namespace sendmsg; class Sms { /* * 發送手機短信 * @param unknown $mobile 手機號 * @param unknown $content 短信內容 */ public function send( $mobile , $content ) { return $this ->mysend_sms( $mobile , $content ); } private function mysend_sms( $mobile , $content ) { $user_id = urlencode(config( 'mobile_username' )); $mobile_pwd = urlencode(config( 'mobile_pwd' )); $sign = urlencode(config( 'mobile_signature' )); if (! $mobile || ! $content || ! $user_id || ! $mobile_pwd ) return false; if ( is_array ( $mobile )) { $mobile = implode( "," , $mobile ); } $mobile =urlencode( $mobile ); $content =urlencode( $content ); $url = 'http://api.smsbao.com/sms?u=' . $user_id . '&p=' .md5( $mobile_pwd ). '&m=' . $mobile . '&c=【' . $sign . '】' . $content ; if (function_exists( 'file_get_contents' )) { $res = file_get_contents ( $url ); } else { $ch = curl_init(); $timeout = 5; curl_setopt( $ch , CURLOPT_URL, $url ); curl_setopt( $ch , CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch , CURLOPT_CONNECTTIMEOUT, $timeout ); $res = curl_exec( $ch ); curl_close( $ch ); } if ( $res == 0) { return true; } return false; } } |
好了,經過以上的替換,短信寶的短信平臺已經替換成功了,我們去進行發送測試:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,并且免審核了,短信內容3~5秒就可送達。
最新更新
電商類
CMS類
微信類