逍遙商城是一個以PHP+MySQL進(jìn)行開發(fā)的開源B2C商城。在廣大站長里面挺受喜愛,小編對他還是很了解,今天小編就以新增短信接口為例,給大家講解一下如何進(jìn)行二次開發(fā),我們今天講解的是V1.1.1版本,使用的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信群發(fā)平臺的接口非常穩(wěn)定,發(fā)送速度快,注冊就送測試短信,推薦大家使用。
1:打開項(xiàng)目:\admin\template\setting_sms.html 大概在10行修改為短信寶短信頁面
|
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
|
<div class="right"> <!--{include(pe_tpl('setting_menu.html','admin'));}--> <div class="right_main"> <div class="tixing corg"> <p>短信使用的是短信寶,可以先注冊一個短信寶的帳號<a href="http://smsbao.com/reg" class="cblue" target="_blank">申請帳號</a></p> </div> <form method="post" id="form"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="wenzhang mat20 mab20"> <tr> <td align="right" width="150">短信寶賬號:</td> <td><input type="text" name="info[sms_key]" value="{$info['sms_key']['setting_value']}" class="inputall input300" /></td> </tr> <tr> <td align="right" width="150">短信寶密碼:</td> <td><input type="text" name="info[sms_secret]" value="{$info['sms_secret']['setting_value']}" class="inputall input300" /></td> </tr> <tr> <td align="right">短信寶簽名:</td> <td><input type="text" name="info[sms_sign]" value="{$info['sms_sign']['setting_value']}" class="inputall input300" /> <span class="c999">(例:逍遙商城 要與短信寶中的簽名保持一致哦)</span></td> </tr> <tr> <td align="right">管理員手機(jī)號:</td> <td> <input type="text" name="info[sms_admin]" value="{$info['sms_admin']['setting_value']}" class="inputall input300" /> </td> </tr> <tr> <td></td> <td> <input type="hidden" name="pesubmit" /> <input type="hidden" name="pe_token" value="{$pe_token}" /> <input type="submit" value="提 交" class="tjbtn" /> </td> </tr> </table> </form> </div> |
2:打開項(xiàng)目:\hook\notice.hook.php 修改用戶通知和管理員通知函數(shù)
|
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
|
if ($notice['user']['notice_sms_state'] && $info['user_phone']) { $info_list['noticelog_type'] = 'sms'; $info_list['noticelog_user'] = $info['user_phone']; $info_list['noticelog_name'] = ''; $info_list['noticelog_text'] = "【{$cache_setting['sms_sign']}】".notice_tag_replace($notice['user']['notice_sms_text'], $info); $info_list['noticelog_atime'] = time(); if(isset($_SESSION['sms_param'])){ $sms_param = "{".rtrim($_SESSION['sms_param'],",")."}"; if (qunfa_sms($info['user_phone'],$sms_param,$notice['user']['notice_sms_text'])){ $info_list['noticelog_state'] = 'success'; }else{ $info_list['noticelog_state'] = 'fail'; } unset($_SESSION['sms_param']); } $sql_set[] = pe_dbhold($info_list); } //發(fā)送管理員短信通知 if ($notice['admin']['notice_sms_state'] && $cache_setting['sms_admin']) { foreach (explode(',', $cache_setting['sms_admin']) as $v) { $info_list['noticelog_type'] = 'sms'; $info_list['noticelog_user'] = $v; $info_list['noticelog_name'] = ''; $info_list['noticelog_text'] = "【{$cache_setting['sms_sign']}】".notice_tag_replace($notice['admin']['notice_sms_text'], $info); $info_list['noticelog_atime'] = time(); if(isset($_SESSION['sms_param'])){ $sms_param = '{'.rtrim($_SESSION['sms_param'],",").'}'; if (qunfa_sms($cache_setting['sms_admin'],$sms_param,$notice['admin']['notice_sms_text'])){ $info_list['noticelog_state'] = 'success'; }else{ $info_list['noticelog_state'] = 'fail'; } unset($_SESSION['sms_param']); } $sql_set[] = pe_dbhold($info_list); } } if (is_array($sql_set)) $db->pe_insert('noticelog', $sql_set); add_wechat_noticelog($user_id, $type, $info);}function remove_quote(&$str) { if (preg_match("/^\'/",$str)){ $str = substr($str, 1, strlen($str) - 1); } //判斷字符串是否以'"'結(jié)束 if (preg_match("/\'$/",$str)){ $str = substr($str, 0, strlen($str) - 1);; } return $str;} |
3:打開項(xiàng)目:\hook\qunfa.hook.php 修改短信發(fā)送類
|
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
|
function qunfa_sms($phone, $text, $templateid=null, $qunfa_id = 0) { global $db, $cache_setting; if ($templateid == null){ $content = $text; }else { $sms_param = trim($text,"}"); $sms_param = trim($sms_param,"{"); $tpl = $templateid; $arr = explode(',',$sms_param); foreach ($arr as $v) { $key = explode(':',$v); $str = remove_quote($key[1]); $tpl=str_replace('${'.$key[0].'}',$str,$tpl); } $content = '【'.$cache_setting['sms_sign'].'】'.$tpl; } $user = $cache_setting['sms_key']; //短信平臺帳號 $pass = md5($cache_setting['sms_secret']); //短信平臺密碼 $content = $content;//要發(fā)送的短信內(nèi)容 $phone = $phone;//要發(fā)送短信的手機(jī)號碼 $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content); $result =file_get_contents($sendurl); if ($result == 0){ return array('result'=>true, 'show'=>'發(fā)送成功'); }else { return array('result'=>false, 'show'=>'發(fā)送失敗'); }} |
經(jīng)過上面的替換,短信寶的短信平臺已經(jīng)替換成功了,可以正常使用了。進(jìn)行測試發(fā)送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開發(fā)好完整的逍遙商城V1.1.1系統(tǒng)系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類