91成人在线播放_欧美一区二区视频在线观看_91精品国产高清久久久久久_国产精品久久亚洲不卡4k岛国


待發(fā)短信

在線客服
產(chǎn)品支持 短信寶客服
合作渠道 渠道合作
服務(wù)咨詢

4001-021-502

工作時間

9:00-21:00

WSTMart電子商務(wù)系統(tǒng)短信接口替換

WSTMart電子商務(wù)系統(tǒng)是基于ThinkPHP5.0開發(fā)的B2B2C綜合電子商務(wù)系統(tǒng),安裝此程序要確保PHP版本高于5.4,最好5.5(支持PHP7),因為是thinkphp框架,所以二開比較方便,注釋也清晰,小編對于此系統(tǒng)還是比較了解的,今天小編就以替換短信接口為例為大家講解一下如何進行二次開發(fā),我們今天講解的是2.0版本,使用的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信群發(fā)平臺非常穩(wěn)定,發(fā)送速度快,注冊就送測試短信,推薦大家使用。

進行接口替換我們首先進行修改短信配置界面,打開項目\wstmart\admin\view\sysconfigs\config1.html 文件,大約在41-77行左右,修改如下代碼:

?
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
    <tr>
             <td colspan='2' class='head-ititle'>短信服務(wù)器設(shè)置</td>
          </tr>
          <tr>
             <th>開啟手機驗證:</th>
             <td>
             <label>
                 <input type='radio' id='smsOpen1' name='smsOpen' class='ipt' value='1' {if $object['smsOpen']==1}checked{/if}/>是
             </label>
             <label>
                 <input type='radio' id='smsOpen0' name='smsOpen' class='ipt' value='0' {if $object['smsOpen']==0}checked{/if}/>否
             </label>
             </td>
          </tr>
          <tr>
             <th>短信寶賬號:</th>
             <td><input type="text" id='smsKey' class='ipt' value="{$object['smsKey']}" maxLength='100'/>&nbsp;&nbsp;還沒有帳號?點擊<a target='_blank' href='http://www.gjrencai.com/reg'>注冊</a></td>
          </tr>
          <tr>
             <th>短信寶密碼:</th>
             <td><input type="text" id='smsPass' class='ipt' value="{$object['smsPass']}" maxLength='100'/></td>
          </tr>
          <tr>
             <th>號碼每日發(fā)送數(shù):</th>
             <td><input type="text" id='smsLimit' class='ipt' value="{$object['smsLimit']}" maxLength='100'/></td>
          </tr>
          <tr>
             <th>開啟短信發(fā)送驗證碼:</th>
             <td>
             <label>
                 <input type='radio' id='smsVerfy1' class='ipt' name='smsVerfy' value='1' {if $object['smsVerfy']==1}checked{/if}/>是
             </label>
             <label>
                 <input type='radio' id='smsVerfy0' class='ipt' name='smsVerfy' value='0' {if $object['smsVerfy']==0}checked{/if}/>否
             </label>
             </td>
          </tr>

經(jīng)過上面的替換,后臺顯示頁面就是短信寶的了,接下來我們?nèi)ピ黾游覀兌绦艑毜慕涌诖a,打開項目\wstmart\common\common\function.php 文件,增加以下代碼:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * 短信寶短信服務(wù)商
 * @param string $phoneNumer  手機號碼
 * @param string $content     短信內(nèi)容
 */
function SmsbaoSMS($phoneNumer,$content){
        $url 'http://api.smsbao.com/sms?u='.WSTConf("CONF.smsKey").'&p='.md5(WSTConf("CONF.smsPass")).'&m='.$phoneNumer.'&c='.$content;
        $ch=curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//設(shè)置否輸出到頁面
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30 ); //設(shè)置連接等待時間
        curl_setopt($ch, CURLOPT_ENCODING, "gzip" );
        $data=curl_exec($ch);
        curl_close($ch);
        return $data;
}

最后我們?nèi)バ薷恼{(diào)用接口的文件,打開項目\wstmart\common\model\LogSms.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
55
56
57
58
59
60
61
62
63
64
<?php
namespace wstmart\common\model;
/**
 
 * 短信日志類
 */
class LogSms extends Base{
 
        /**
         * 寫入并發(fā)送短訊記錄
         */
        public function sendSMS($smsSrc,$phoneNumber,$content,$smsFunc,$verfyCode){
                $USER = session('WST_USER');
                $userId empty($USER)?0:$USER['userId'];
                $ip = request()->ip();
                //檢測短信驗證碼驗證是否正確
                if(WSTConf("CONF.smsVerfy")==1){
                        $smsverfy = input("post.smsVerfy");
                        $rs = WSTVerifyCheck($smsverfy);
                        if(!$rs){
                                return WSTReturn("驗證碼不正確!",-2);
                        }
                }
                //檢測是否超過每日短信發(fā)送數(shù)
                $date date('Y-m-d');
                $smsRs $this->field("count(smsId) counts,max(createTime) createTime")
                                           ->where(["smsPhoneNumber"=>$phoneNumber])
                                   ->whereTime('createTime''between', [$date.' 00:00:00'$date.' 23:59:59'])->find();
                if($smsRs['counts']>(int)WSTConf("CONF.smsLimit")){
                        return WSTReturn("請勿頻繁發(fā)送短信驗證!");
                }
                if($smsRs['createTime'] !='' && ((time()-strtotime($smsRs['createTime']))<120)){
                        return WSTReturn("請勿頻繁發(fā)送短信驗證!");
                }
                //檢測IP是否超過發(fā)短信次數(shù)
                $ipRs $this->field("count(smsId) counts,max(createTime) createTime")
                                         ->where(["smsIP"=>$ip])
                                         ->whereTime('createTime''between', [$date.' 00:00:00'$date.' 23:59:59'])->find();
                if($ipRs['counts']>(int)WSTConf("CONF.smsLimit")){
                        return WSTReturn("請勿頻繁發(fā)送短信驗證!");
                }
                if($ipRs['createTime']!='' && ((time()-strtotime($ipRs['createTime']))<120)){
                        return WSTReturn("請勿頻繁發(fā)送短信驗證!");
                }
 
                $code = SmsbaoSMS($phoneNumber,$content);
                $data array();
                $data['smsSrc'] = $smsSrc;
                $data['smsUserId'] = $userId;
                $data['smsPhoneNumber'] = $phoneNumber;
                $data['smsContent'] = $content;
                $data['smsReturnCode'] = $code;
                $data['smsCode'] = $verfyCode;
                $data['smsIP'] = $ip;
                $data['smsFunc'] = $smsFunc;
                $data['createTime'] = date('Y-m-d H:i:s');
                $this->data($data)->save();
                if(intval($code) == 0){
                        return WSTReturn("短信發(fā)送成功!",1);
                }else{
                        return WSTReturn("短信發(fā)送失敗!");
                }
        }
}

好了,經(jīng)過以上的替換,短信寶的短信平臺已經(jīng)替換成功了,我們?nèi)ミM行發(fā)送測試:

報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會人工審核,短信內(nèi)容3~5秒就可送達(dá)。

另外:我們已經(jīng)開發(fā)好完整的WSTMart電子商務(wù)系統(tǒng)短信寶插件,點擊此鏈接 下載及查看安裝流程。

開源插件

最新更新

電商類

CMS類

微信類

文章標(biāo)簽