DSSHOP是基于DSMall(B2B2C商城)分離出來的單店鋪B2C商城系統(tǒng),基于國內(nèi)優(yōu)秀開源框架THinkPHP、打造出的一套開源的B2C電子商務(wù)系統(tǒng)。今天小編就以DSShop單店鋪1.5版本的替換短信接口為例告訴大家如何進(jìn)行二次開發(fā),使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的接口,我們短信寶短信群發(fā)平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用。
首先打開項(xiàng)目:\application\admin\view\message\mobile.html 文件,替換17~31行代碼
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<tr class="noborder"> <td class="required w120">短信寶用戶名</td> <td class="vatop rowform"> <input type="text" name="smscf_wj_username" id="smscf_wj_username" value="{$list_config.smscf_wj_username}" class="w200"/> </td> <td class="vatop tips"></td></tr><tr class="noborder"> <td class="required w120">短信寶密碼</td> <td class="vatop rowform"> <input type="text" name="smscf_wj_key" id="smscf_wj_key" value="{$list_config.smscf_wj_key}" class="w200"/> </td> <td class="vatop tips"></td></tr> |
接著打開項(xiàng)目:\application\admin\controller\Message.php文件,替換mobile方法
|
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
|
public function mobile() { $config_model = model('config'); if (!(request()->isPost())) { $list_config = $config_model->getConfigList(); $smscf_wj_num = ''; if(!empty($list_config['smscf_wj_username'])&&!empty($list_config['smscf_wj_key'])){ //如果配置了信息,可以查看具體可用短信條數(shù) $smscf_wj_num = http_request('http://www.gjrencai.com/query?u='.$list_config['smscf_wj_username'].'&p='.md5($list_config['smscf_wj_key']),'get'); $smscf_wj_num = explode(',', $smscf_wj_num); if ($smscf_wj_num[0] == 0) { $smscf_wj_num = $smscf_wj_num[1]; }else{ $smscf_wj_num = 0; } } $this->assign('smscf_wj_num', $smscf_wj_num); $this->assign('list_config', $list_config); $this->setAdminCurItem('mobile'); return $this->fetch('mobile'); } else { $update_array = array(); $update_array['smscf_wj_username'] = input('post.smscf_wj_username'); $update_array['smscf_wj_key'] = input('post.smscf_wj_key'); $update_array['sms_register'] = input('post.sms_register'); $update_array['sms_login'] = input('post.sms_login'); $update_array['sms_password'] = input('post.sms_password'); $result = $config_model->editConfig($update_array); if ($result === true) { $this->log(lang('ds_edit') . lang('mobile_set'), 1); $this->success(lang('ds_common_save_succ')); } else { $this->log(lang('ds_edit') . lang('mobile_set'), 0); $this->error(lang('ds_common_save_fail')); } } } |
接著打開項(xiàng)目:\extend\sendmsg\Sms.php文件,替換mysend_sms方法
|
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
|
private function mysend_sms($mobile, $content) { $user_id = config('smscf_wj_username'); // 這里填寫用戶名 $key = config('smscf_wj_key'); // 這里填接口安全密鑰 if (!$mobile || !$content || !$user_id || !$key) return false; if (is_array($mobile)) { $mobile = implode(",", $mobile); } 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; } |
經(jīng)過上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。進(jìn)行測(cè)試發(fā)送:

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開發(fā)好完整的DSShop商城系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類