DSSHOP是基于DSMall(B2B2C商城)分離出來的單店鋪B2C商城系統,基于國內優秀開源框架THinkPHP、打造出的一套開源的B2C電子商務系統。今天小編就以DSShop單店鋪1.5版本的替換短信接口為例告訴大家如何進行二次開發,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先打開項目:\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> |
接著打開項目:\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' ])){ //如果配置了信息,可以查看具體可用短信條數 $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' )); } } } |
接著打開項目:\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; } |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的DSShop商城系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類