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


待發短信

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

4001-021-502

工作時間

9:00-21:00

DSShop_V3.1單店鋪商城系統新增短信寶短信接口

DSSHOP是基于DSMall(B2B2C商城)分離出來的單店鋪B2C商城系統,基于國內優秀開源框架THinkPHP、打造出的一套開源的B2C電子商務系統。今天小編就以DSShop單店鋪3.1版本的替換短信接口為例告訴大家如何進行二次開發,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
覆蓋之后執行以下sql,表名`ds_config` 根據自定義前綴進行修改:

1
INSERT INTO `ds_config` ( `code`, `value`, `remark`) VALUES('smscf_smsbao_id''''短信寶賬號'),('smscf_smsbao_secret''''短信寶APIKEY');

1.首先我們打開項目app\admin\view\message\mobile.html文件,替換以下代碼:

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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
{include file="public/header" /}
 
 
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.ds_message}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <form method="post">
        <table class="ds-default-table">
            <tbody>
            <tr>
                <td class="required w120">{$Think.lang.smscf_sign}</td>
                <td class="vatop rowform">
                    <input type="text" name="smscf_sign" id="smscf_sign" value="{$list_config.smscf_sign}" class="w200"/>
                </td>
                <td class="vatop tips">{$Think.lang.smscf_sign_tips}</td>
            </tr>
            <tr>
                <td class="required w120">{$Think.lang.smscf_type}</td>
                <td class="vatop rowform">
                    <select id="smscf_type" name="smscf_type">
                        <option value="wj" {if $list_config.smscf_type=='wj'}selected{/if}>{$Think.lang.smscf_type_wj}</option>
                        <option value="ali" {if $list_config.smscf_type=='ali'}selected{/if}>{$Think.lang.smscf_type_ali}</option>
                        <option value="ten" {if $list_config.smscf_type=='ten'}selected{/if}>{$Think.lang.smscf_type_ten}</option>
                        <option value="smsbao" {if $list_config.smscf_type=='smsbao'}selected{/if}>{$Think.lang.smscf_type_smsbao}</option>
                    </select>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_wj" {if $list_config.smscf_type!='wj'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.smscf_wj_username}</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 smscf_type_wj" {if $list_config.smscf_type!='wj'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.smscf_wj_key}</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>
            {notempty name='smscf_num'}
            <tr class="noborder">
                <td class="required w120">{$Think.lang.smscf_num}</td>
                <td>{$smscf_num}</td>
                <td class="vatop tips"></td>
            </tr>
            {/notempty}
             <tr class="noborder smscf_type_smsbao" {if $list_config.smscf_type!='smsbao'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.smscf_smsbao_id}</td>
                <td class="vatop rowform">
                    <input type="text" name="smscf_smsbao_id" id="smscf_smsbao_id" value="{$list_config.smscf_smsbao_id}" class="w200"/>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_smsbao" {if $list_config.smscf_type!='smsbao'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.smscf_smsbao_secret}</td>
                <td class="vatop rowform">
                    <input type="text" name="smscf_smsbao_secret" id="smscf_smsbao_secret" value="{$list_config.smscf_smsbao_secret}" class="w200"/>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_ali" {if $list_config.smscf_type!='ali'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.smscf_ali_id}</td>
                <td class="vatop rowform">
                    <input type="text" name="smscf_ali_id" id="smscf_ali_id" value="{$list_config.smscf_ali_id}" class="w200"/>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_ali" {if $list_config.smscf_type!='ali'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.smscf_ali_secret}</td>
                <td class="vatop rowform">
                    <input type="text" name="smscf_ali_secret" id="smscf_ali_secret" value="{$list_config.smscf_ali_secret}" class="w200"/>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_ten" {if $list_config.smscf_type!='ten'}style="display:none"{/if}>
            <td class="required w120">{$Think.lang.smscf_ten_id}</td>
            <td class="vatop rowform">
                <input type="text" name="smscf_ten_id" id="smscf_ten_id" value="{$list_config.smscf_ten_id}" class="w200"/>
            </td>
            <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_ten" {if $list_config.smscf_type!='ten'}style="display:none"{/if}>
            <td class="required w120">{$Think.lang.smscf_ten_secret}</td>
            <td class="vatop rowform">
                <input type="text" name="smscf_ten_secret" id="smscf_ten_secret" value="{$list_config.smscf_ten_secret}" class="w200"/>
            </td>
            <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required w120">{$Think.lang.sms_register}</td>
                <td class="vatop rowform">
                    <div class="onoff">
                        <label for="sms_register_show1" class="cb-enable {if condition="$list_config.sms_register eq 1"}selected{/if}">{$Think.lang.ds_yes}</label>
                        <label for="sms_register_show0" class="cb-disable {if condition="$list_config.sms_register eq 0"}selected{/if}">{$Think.lang.ds_no}</label>
                        <input id="sms_register_show1" name="sms_register" value="1" type="radio" {if condition="$list_config.sms_register eq 1"checked="checked"{/if}>
                        <input id="sms_register_show0" name="sms_register" value="0" type="radio" {if condition="$list_config.sms_register eq 0"checked="checked"{/if}>
                    </div>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required">{$Think.lang.sms_login}</td>
                <td class="vatop rowform">
                    <div class="onoff">
                        <label for="sms_login_show1" class="cb-enable {if condition="$list_config.sms_login eq 1"}selected{/if}">{$Think.lang.ds_yes}</label>
                        <label for="sms_login_show0" class="cb-disable {if condition="$list_config.sms_login eq 0"}selected{/if}">{$Think.lang.ds_no}</label>
                        <input id="sms_login_show1" name="sms_login" value="1" type="radio" {if condition="$list_config.sms_login eq 1"checked="checked"{/if}>
                        <input id="sms_login_show0" name="sms_login" value="0" type="radio" {if condition="$list_config.sms_login eq 0"checked="checked"{/if}>
                    </div>
                </td>
            </tr>
            <tr class="noborder">
                <td class="required">{$Think.lang.sms_password}</td>
                <td class="vatop rowform">
                    <div class="onoff">
                        <label for="sms_password_show1" class="cb-enable {if condition="$list_config.sms_password eq 1"}selected{/if}">{$Think.lang.ds_yes}</label>
                        <label for="sms_password_show0" class="cb-disable {if condition="$list_config.sms_password eq 0"}selected{/if}">{$Think.lang.ds_no}</label>
                        <input id="sms_password_show1" name="sms_password" value="1" type="radio" {if condition="$list_config.sms_password eq 1"checked="checked"{/if}>
                        <input id="sms_password_show0" name="sms_password" value="0" type="radio" {if condition="$list_config.sms_password eq 0"checked="checked"{/if}>
                    </div>
                </td>
            </tr>
            <tr class="noborder">
                <td class="required w120">{$Think.lang.test_mobile_address}</td>
                <td class="vatop rowform">
                    <input type="text" name="mobile_test" id="mobile_test" value="" class="w200"/>
                    <input type="button" value="{$Think.lang.test_mail}" name="send_test_mobile" class="btn btn-small" id="send_test_mobile" >
                </td>
            </tr>
            <tr class="noborder smscf_type_ali" {if $list_config.smscf_type!='ali'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.ali_template_code}</td>
                <td class="vatop rowform">
                    <input type="text" name="ali_template_code" id="ali_template_code" value="" class="w200"/>
                </td>
            </tr>
            <tr class="noborder smscf_type_ali" {if $list_config.smscf_type!='ali'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.ali_template_content}</td>
                <td class="vatop rowform">
                    <textarea name="ali_template_content" id="ali_template_content" class="w200"></textarea>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_ali" {if $list_config.smscf_type!='ali'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.ali_template_param}</td>
                <td class="vatop rowform">
                    <textarea name="ali_template_param" id="ali_template_param" class="w200"></textarea>
                </td>
                <td class="vatop tips">{$Think.lang.ali_template_param_tips}</td>
            </tr>
            <tr class="noborder smscf_type_ten" {if $list_config.smscf_type!='ten'}style="display:none"{/if}>
            <td class="required w120">{$Think.lang.ten_template_code}</td>
            <td class="vatop rowform">
                <input type="text" name="ten_template_code" id="ten_template_code" value="" class="w200"/>
            </td>
            </tr>
            <tr class="noborder smscf_type_ten" {if $list_config.smscf_type!='ten'}style="display:none"{/if}>
            <td class="required w120">{$Think.lang.ten_template_content}</td>
            <td class="vatop rowform">
                <textarea name="ten_template_content" id="ten_template_content" class="w200"></textarea>
            </td>
            <td class="vatop tips"></td>
            </tr>
            <tr class="noborder smscf_type_ten" {if $list_config.smscf_type!='ten'}style="display:none"{/if}>
            <td class="required w120">{$Think.lang.ten_template_param}</td>
            <td class="vatop rowform">
                <textarea name="ten_template_param" id="ten_template_param" class="w200"></textarea>
            </td>
            <td class="vatop tips">{$Think.lang.ten_template_param_tips}</td>
            </tr>
            <tr class="noborder smscf_type_wj" {if $list_config.smscf_type!='wj'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.test_mobile_content}</td>
                <td class="vatop rowform">
                    <textarea name="mobile_test_content" id="mobile_test_content" class="w200"></textarea>
                </td>
            </tr>
            <tr class="noborder smscf_type_smsbao" {if $list_config.smscf_type!='smsbao'}style="display:none"{/if}>
                <td class="required w120">{$Think.lang.test_mobile_content}</td>
                <td class="vatop rowform">
                    <textarea name="smsbao_test_mobile_content" id="smsbao_test_mobile_content" class="w200"></textarea>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr class="tfoot">
                <td></td>
                <td colspan="15"><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
            </tr>
            </tfoot>
        </table>
    </form>
 
</div>
<script>
    $(document).ready(function(){
        $('#send_test_mobile').click(function(){
            $.ajax({
                type:'POST',
                url:"{:url('Message/mobile_testing')}",
                data:{
                    'smscf_sign':$('#smscf_sign').val(),
                    'smscf_type':$('#smscf_type').val(),
                    'smscf_smsbao_secret':$('#smscf_smsbao_secret').val(),
                    'smscf_smsbao_id':$('#smscf_smsbao_id').val(),
                    'smscf_ali_secret':$('#smscf_ali_secret').val(),
                    'smscf_ali_id':$('#smscf_ali_id').val(),
                    'ali_template_content':$('#ali_template_content').val(),
                    'ali_template_param':$('#ali_template_param').val(),
                    'ali_template_code':$('#ali_template_code').val(),
                    'smscf_ten_secret':$('#smscf_ten_secret').val(),
                    'smscf_ten_id':$('#smscf_ten_id').val(),
                    'ten_template_content':$('#ten_template_content').val(),
                    'ten_template_param':$('#ten_template_param').val(),
                    'ten_template_code':$('#ten_template_code').val(),
                    'mobile_test_content':$('#mobile_test_content').val(),
                    'smsbao_test_mobile_content':$('#smsbao_test_mobile_content').val(),
                    'smscf_wj_username':$('#smscf_wj_username').val(),
                    'smscf_wj_key':$('#smscf_wj_key').val(),
                    'mobile_test':$('#mobile_test').val()
                },
                error:function(html){
                    layer.alert('{$Think.lang.ds_common_op_fail}');
                },
                success:function(html){
                    if(html.msg){
                        layer.alert(html.msg);
                    }
                },
                dataType:'json'
            });
        });
        $('#smscf_type').change(function(){
            if($(this).val()=='wj'){
                $('.smscf_type_ali').hide()
                $('.smscf_type_wj').show()
                $('.smscf_type_ten').hide()
                $('.smscf_type_smsbao').hide()
            }
            if($(this).val()=='ali'){
                $('.smscf_type_ali').show()
                $('.smscf_type_wj').hide()
                $('.smscf_type_ten').hide()
                $('.smscf_type_smsbao').hide()
            }
            if($(this).val()=='ten'){
                $('.smscf_type_ali').hide()
                $('.smscf_type_wj').hide()
                $('.smscf_type_ten').show()
                $('.smscf_type_smsbao').hide()
            }
             if($(this).val()=='smsbao'){
                $('.smscf_type_ali').hide()
                $('.smscf_type_wj').hide()
                $('.smscf_type_ten').hide()
                $('.smscf_type_smsbao').show()
            }
        })
    });
</script>

2.接著打開項目app\admin\lang\zh-cn\message.lang.php 文件,在83~85行增加以下代碼:

1
2
3
$lang['smscf_type_smsbao'] = '短信寶';
$lang['smscf_smsbao_id'] = '短信寶賬號';
$lang['smscf_smsbao_secret'] = '短信寶APIKEY';

3.接著打開項目app\admin\controller\Message.php 文件,替換mobile_testing 方法

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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 /**
     * 測試手機短信發送
     *
     * @param
     * @return
     */
    public function mobile_testing() {
        $mobile = input('param.mobile_test');
        $smsContent = input('param.smsbao_test_mobile_content');
        $content = input('param.mobile_test_content');
        $smscf_type = input('param.smscf_type');
        $smscf_smsbao_id = input('param.smscf_smsbao_id');
        $smscf_smsbao_secret = input('param.smscf_smsbao_secret');
        $smscf_ali_id = input('param.smscf_ali_id');
        $smscf_ali_secret = input('param.smscf_ali_secret');
        $ali_template_param=input('param.ali_template_param');
        $ali_template_code=input('param.ali_template_code');
        $ali_template_content=input('param.ali_template_content');
        $smscf_ten_id = input('param.smscf_ten_id');
        $smscf_ten_secret = input('param.smscf_ten_secret');
        $ten_template_param = input('param.ten_template_param');
        $ten_template_code = input('param.ten_template_code');
        $ten_template_content = input('param.ten_template_content');
        $user_id = urlencode(input('param.smscf_wj_username')); // 這里填寫用戶名
        $key = urlencode(input('param.smscf_wj_key')); // 這里填接口安全密鑰
        $smscf_sign = input('param.smscf_sign');
        config('ds_config.smscf_type',$smscf_type);
        config('ds_config.smscf_wj_username',$user_id);
        config('ds_config.smscf_wj_key',$key);
        config('ds_config.smscf_smsbao_id',$smscf_smsbao_id);
        config('ds_config.smscf_smsbao_secret',$smscf_smsbao_secret);
        config('ds_config.smscf_ali_id',$smscf_ali_id);
        config('ds_config.smscf_ali_secret',$smscf_ali_secret);
        config('ds_config.smscf_ten_id'$smscf_ten_id);
        config('ds_config.smscf_ten_secret'$smscf_ten_secret);
        config('ds_config.smscf_sign'$smscf_sign);
        $smslog_param array(
            'ali_template_code' => $ali_template_code,
            'ali_template_param' => array(),
            'ten_template_code' => $ten_template_code,
            'ten_template_param' => array(),
        );
        $smslog_param=array(
                    'ali_template_code'=>$ali_template_code,
                    'ali_template_param'=>array(),
                );
        if($smscf_type=='wj'){
            $smslog_param['message']=$content;
        }elseif($smscf_type=='smsbao'){
            $smslog_param['message']=$smsContent;
        }elseif($smscf_type=='ali'){
            $param=json_decode(htmlspecialchars_decode($ali_template_param),true);
            if(!$param){
                echo json_encode(array('msg'=>lang('ali_template_param_error')));exit;
            }
            $smslog_param['message'] = ds_replace_text(htmlspecialchars_decode($ali_template_content), $param);
            $smslog_param['ali_template_param']= $param;
        }elseif ($smscf_type == 'ten') {
            $param = json_decode(htmlspecialchars_decode($ten_template_param), true);
            if (!$param) {
                echo json_encode(array('msg' => lang('ten_template_param_error')));
                exit;
            }
            $smslog_param['message'] = ds_replace_text(htmlspecialchars_decode($ten_template_content), $param);
            $smslog_param['ten_template_param'] = $param;
        }else{
            echo json_encode(array('msg' => lang('param_error')));
            exit;
        }
 
        $result=model('smslog')->sendSms($mobile$smslog_param);
 
        if ($result['code'] == 10000){
            $data['msg'] = '測試手機短信發送成功';
        }else{
            $data['msg'] = $result['message'];
        }
        echo json_encode($data);
        exit;
    }

4.接著打開項目extend\sendmsg\Sms.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
public function smsbao_send($mobile$content) {
        $user_id = config('ds_config.smscf_smsbao_id'); 
        $key = config('ds_config.smscf_smsbao_secret');
        if (!$mobile || !$content || !$user_id || !$key)
            return false;
        if (is_array($mobile)) {
            $mobile = implode(","$mobile);
        }
        $mobile=urlencode($mobile);
        $content=urlencode($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);
        }
 
        //短信發送后返回值 說明
 
         $statusStr array(
        "0" => "短信發送成功",
        "-1" => "參數不全",
        "-2" => "服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!",
        "30" => "密碼錯誤",
        "40" => "賬號不存在",
        "41" => "余額不足",
        "42" => "帳戶已過期",
        "43" => "IP地址限制",
        "50" => "內容含有敏感詞"
        );
        $message $statusStr[$res];
        if($res == 0){
            return ds_callback(true);
        }else{
            return ds_callback(false,$message);
        }
    }

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

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

開源插件

最新更新

電商類

CMS類

微信類

文章標簽