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


待發短信

在線客服
產品支持 短信寶客服
合作渠道 渠道合作
服務咨詢

4001-021-502

工作時間

9:00-21:00

DsMall商城新增短信寶短信接口

DSMall基于國內優秀開源框架THinkPHP、打造出的一套開源的B2B2C電子商務系統。小編帶著大家一起開發DSMall商城3.1.1的短信寶插件接口。我們使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。

首先我們打開項目application\admin\view\message\mobile.html文件,替換17~37行代碼:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<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"/>
        <a href="http://www.baidu.com/reg/" target="_blank" class="btn btn-blue btn-mini">立即申請</a>
    </td>
    <td class="vatop tips"></td>
</tr>
{notempty name='smscf_wj_num'}
<tr class="noborder">
    <td class="required w120">可用短信條數</td>
    <td>{$smscf_wj_num}</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 = rkcache('config', true);
        
        $smscf_wj_num '';
        if(!empty($list_config['smscf_wj_username'])&&!empty($list_config['smscf_wj_key'])){
            //如果配置了信息,可以查看具體可用短信條數
            $smscf_wj_num = http_request('http://api.smsbao.com/query?u='.$list_config['smscf_wj_username'].'&p='.md5($list_config['smscf_wj_key']),'get');
            if ($smscf_wj_num) {
                $smscf_wj_num explode(','$smscf_wj_num);
                $smscf_wj_num $smscf_wj_num[1];
            }else{
                $smscf_wj_num '';
            }
        }
        $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
29
30
31
32
33
34
35
36
 private function mysend_sms($mobile$content)
    {
        $smsbao_user = urlencode(config('smsbao_user')); // 戶名
        $smsbao_pwd = urlencode(config('smsbao_pass')); // 這里填接口安全密鑰
        $smsbao_sign = urlencode(config('smsbao_sign')); 
        
        if (!$mobile || !$content || !$smsbao_user || !$smsbao_pwd || !$smsbao_sign)
            return false;
        if (is_array($mobile)) {
            $mobile = implode(","$mobile);
        }
        
        $mobile=urlencode($mobile);
        $content=urlencode($content);
        $url 'http://api.smsbao.com/sms?u='.$smsbao_user.'&p='.md5($smsbao_pwd).'&m='.$mobile.'&c='.$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秒就可送達。

另外:我們已經開發好完整的DsMall商城系統短信寶插件,點擊此鏈接 下載及查看安裝流程。

 

開源插件

最新更新

電商類

CMS類

微信類

文章標簽