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


待發短信

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

4001-021-502

工作時間

9:00-21:00

DBShop短信接口替換

DBShop基于PHP官方ZendFramework 2框架開發的新一代電子商務系統(完美支持 PHP7)。方便的操作管理、詳細的使用教程、自動化的在線處理,便于進行二次開發,小編對這款軟件還比較熟悉,今天小編就以增加短信接口為例,一步步教大家如何進行二次開發,短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶非常穩定,發送速度快,注冊就送測試條數,推薦大家使用。

首先我們修改后臺模版文件,打開項目\module\system\view\system\system\phpone-message-set.phtml文件,修改代碼如下:

?
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
<div class="tabbable tabs-left">
    <ul class="nav nav-tabs">
        <li><h5><?php echo $this->translate('短信提醒設置'); ?></h5></li>
        <li class="active"><a data-toggle="tab" href="#system_a"><?php echo $this->translate('基本信息'); ?></a></li>
    </ul>
    <form class="form-horizontal" name="phone_message_form" id="phone_message_form" method="post">
        <div class="tab-content">
            <div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
                <div class="pull-left" style="font-size:16px;line-height:30px;"><strong><?php echo $this->translate('短信提醒設置'); ?></strong></div>
                <div class="pull-right">
                    <a href="<?php echo $this->serverUrl(true); ?>" class="btn btn-small btn-warning"><i class="icon-repeat icon-white"></i> <?php echo $this->translate('刷新'); ?></a>
                    &nbsp;<button type="submit" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存提醒設置'); ?></button>
                    &nbsp;<a href="<?php echo $this->myviewalias()->dbshopHelpUrl('phone_message_set'); ?>" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看幫助說明'); ?></a>
                </div>
            </div>
            <div id="system_a" class="tab-pane active">
                <div class="well admin_add_header_well"><?php echo $this->translate('手機短信'); ?></div>
                <div class="well admin_add_well">
                    <div class="message_one">
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('設置類型'); ?>:</label>
                        <div class="controls">
                            <select name="phone_sms_type" id="phone_sms_type" onchange="select_phone_sms_type();" class="span2">
                                <option value="" <?php if(!isset($this->phonesms_config['shop_phone_sms']['phone_sms_type']) or empty($this->phonesms_config['shop_phone_sms']['phone_sms_type'])) echo 'selected="selected"'; ?>><?php echo $this->translate('無類型'); ?></option>
                                <option value="alidayu" <?php if(isset($this->phonesms_config['shop_phone_sms']['phone_sms_type']) and $this->phonesms_config['shop_phone_sms']['phone_sms_type'] == 'alidayu') echo 'selected="selected"'; ?>><?php echo $this->translate('阿里大于'); ?></option>
                                <option value="smsbao" <?php if(isset($this->phonesms_config['shop_phone_sms']['phone_sms_type']) and $this->phonesms_config['shop_phone_sms']['phone_sms_type'] == 'smsbao') echo 'selected="selected"'; ?>><?php echo $this->translate('短信寶'); ?></option>
                            </select>
                            <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('短信寶旗下的通訊平臺。'); ?>"></i>
                            &nbsp;&nbsp;<a href="http://www.gjrencai.com/" target="_blank">查看官方網站</a>
                        </div>
                    </div>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('簽名名稱'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="alidayu_sign_name" id="alidayu_sign_name" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_sign_name'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_sign_name']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label">App Key(<?php echo $this->translate('應用'); ?>):</label>
                        <div class="controls">
                            <input type="text" name="alidayu_app_key" id="alidayu_app_key" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_app_key'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_app_key']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label">App Secret(<?php echo $this->translate('應用'); ?>):</label>
                        <div class="controls">
                            <input type="text" name="alidayu_app_secret" id="alidayu_app_secret" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_app_secret'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_app_secret']); ?>" class="span3">
                        </div>
                    </div>
 
                     <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('短信寶簽名'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="smsbao_sign_name" id="smsbao_sign_name" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_sign_name'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_sign_name']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label">短信寶帳號(<?php echo $this->translate('應用'); ?>):</label>
                        <div class="controls">
                            <input type="text" name="smsbao_app_key" id="smsbao_app_key" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_app_key'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_app_key']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label">短信寶密碼(<?php echo $this->translate('應用'); ?>):</label>
                        <div class="controls">
                            <input type="text" name="smsbao_app_secret" id="smsbao_app_secret" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_app_secret'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_app_secret']); ?>" class="span3">
                        </div>
                    </div>
 
                    <hr>
                    <div class="control-group sms_opinion" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('管理員手機號'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="admin_phone" id="admin_phone" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['admin_phone'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['admin_phone']); ?>" class="span3">
                            <font color="red"><?php echo $this->translate('目前僅支持中國內地手機號碼。'); ?></font>
                        </div>
                    </div>
                    <div class="control-group sms_opinion" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('接收短信'); ?>:</label>
                        <div class="controls">
                            <label class="checkbox inline"><input <?php if(isset($this->phonesms_config['shop_phone_sms']['admin_submit_order_phone_message']) and $this->phonesms_config['shop_phone_sms']['admin_submit_order_phone_message'] == 1) echo 'checked'; ?> type="checkbox" name="admin_submit_order_phone_message" value="1"><?php echo $this->translate('訂單提交'); ?></label>
                            <label class="checkbox inline"><input <?php if(isset($this->phonesms_config['shop_phone_sms']['admin_payment_order_phone_message']) and $this->phonesms_config['shop_phone_sms']['admin_payment_order_phone_message'] == 1) echo 'checked'; ?> type="checkbox" name="admin_payment_order_phone_message" value="1"><?php echo $this->translate('付款完成'); ?></label>
                            <label class="checkbox inline"><input <?php if(isset($this->phonesms_config['shop_phone_sms']['admin_ship_order_phone_message']) and $this->phonesms_config['shop_phone_sms']['admin_ship_order_phone_message'] == 1) echo 'checked'; ?> type="checkbox" name="admin_ship_order_phone_message" value="1"><?php echo $this->translate('發貨完成'); ?></label>
                            <label class="checkbox inline"><input <?php if(isset($this->phonesms_config['shop_phone_sms']['admin_finish_order_phone_message']) and $this->phonesms_config['shop_phone_sms']['admin_finish_order_phone_message'] == 1) echo 'checked'; ?> type="checkbox" name="admin_finish_order_phone_message" value="1"><?php echo $this->translate('確認收貨'); ?></label>
                            <label class="checkbox inline"><input <?php if(isset($this->phonesms_config['shop_phone_sms']['admin_cancel_order_phone_message']) and $this->phonesms_config['shop_phone_sms']['admin_cancel_order_phone_message'] == 1) echo 'checked'; ?> type="checkbox" name="admin_cancel_order_phone_message" value="1"><?php echo $this->translate('取消訂單'); ?></label>
                        </div>
                    </div>
 
 
                    <hr>
                    <div class="alidayu" style="display: none;">
                        <font color="red"><?php echo $this->translate('模板ID是空,為關閉此信息提醒;如果模板ID非空,為開啟此信息提醒。'); ?></font><br>
                        <b>目前官方提供的可設置標簽有 ${buyname} 購買人、${ordersn} 訂單編號、${ordertotal} 訂單金額、${expressname} 快遞名稱、${expressnumber} 快遞單號</b>
                    </div>
 
                     <div class="smsbao" style="display: none;">
                        <font color="red"><?php echo $this->translate('模板內容是空,為關閉此信息提醒;如果模板內容非空,為開啟此信息提醒。'); ?></font><br>
                        <b>目前官方提供的可設置標簽有 ${buyname} 購買人、${ordersn} 訂單編號、${ordertotal} 訂單金額、${expressname} 快遞名稱、${expressnumber} 快遞單號</b>
                    </div>
 
                    <br>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('訂單提交模板ID'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="alidayu_submit_order_template_id" id="alidayu_submit_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_submit_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_submit_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('付款完成模板ID'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="alidayu_payment_order_template_id" id="alidayu_payment_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_payment_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_payment_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('發貨完成模板ID'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="alidayu_ship_order_template_id" id="alidayu_ship_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_ship_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_ship_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('確認收貨模板ID'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="alidayu_finish_order_template_id" id="alidayu_finish_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_finish_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_finish_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('訂單取消模板ID'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="alidayu_cancel_order_template_id" id="alidayu_cancel_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_cancel_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_cancel_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
 
                      <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('訂單提交模板內容'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="smsbao_submit_order_template_id" id="smsbao_submit_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_submit_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_submit_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('付款完成模板內容'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="smsbao_payment_order_template_id" id="smsbao_payment_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_payment_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_payment_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('發貨完成模板內容'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="smsbao_ship_order_template_id" id="smsbao_ship_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_ship_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_ship_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('確認收貨模板內容'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="smsbao_finish_order_template_id" id="smsbao_finish_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_finish_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_finish_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
                    <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('訂單取消模板內容'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="smsbao_cancel_order_template_id" id="smsbao_cancel_order_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_cancel_order_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_cancel_order_template_id']); ?>" class="span3">
                        </div>
                    </div>
 
 
                    <hr>
                    <div class="alidayu" style="display: none;">
                        <b>目前官方提供的可設置標簽有 ${code} 驗證碼 、 ${product} 站點名稱</b>
                    </div>
                    <div class="smsbao" style="display: none;">
                        <b>目前官方提供的可設置標簽有 {code} 驗證碼 、 {product} 站點名稱</b>
                    </div>
                    <br>
                    <div class="control-group alidayu" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('手機驗證碼模板內容'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="alidayu_phone_captcha_template_id" id="alidayu_phone_captcha_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['alidayu_phone_captcha_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['alidayu_phone_captcha_template_id']); ?>" class="span3">
                            <font color="red"><?php echo $this->translate('使用手機驗證碼,要在 系統管理-》系統設置-》驗證碼設置 里開啟手機短信驗證碼。'); ?></font>
                        </div>
                    </div>
 
                    <div class="control-group smsbao" style="display: none;">
                        <label for="input01" class="control-label"><?php echo $this->translate('手機驗證碼模板內容'); ?>:</label>
                        <div class="controls">
                            <input type="text" name="smsbao_phone_captcha_template_id" id="smsbao_phone_captcha_template_id" value="<?php if(isset($this->phonesms_config['shop_phone_sms']['smsbao_phone_captcha_template_id'])) echo $this->escapeHtml($this->phonesms_config['shop_phone_sms']['smsbao_phone_captcha_template_id']); ?>" class="span3">
                            <font color="red"><?php echo $this->translate('使用手機驗證碼,要在 系統管理-》系統設置-》驗證碼設置 里開啟手機短信驗證碼。'); ?></font>
                        </div>
                    </div>
                </div>
            </div>
 
        </div>
    </form>
</div>
<script>
    <?php if ($this->success_msg != '') { ?>
    show_message('.message_one','<?php echo date("Y-m-d H:i:s"); ?>','<?php echo $this->success_msg; ?>','alert-success');
    <?php } ?>
 
 
    function select_phone_sms_type() {
        var phone_sms_type = $("#phone_sms_type").val();
        if(phone_sms_type == '') {
            $(".alidayu").css('display', 'none');
            $('.sms_opinion').css('display', 'none');
        }
        if(phone_sms_type == 'alidayu') {
            $(".alidayu,.sms_opinion").css('display', '');
            $(".smsbao").css('display','none');
        }
        if (phone_sms_type == 'smsbao') {
            $(".smsbao,.sms_opinion").css('display','');
            $(".alidayu").css('display','none');
        }
    }
    <?php if(isset($this->phonesms_config['shop_phone_sms']['phone_sms_type']) and $this->phonesms_config['shop_phone_sms']['phone_sms_type'] != '') { ?>
    select_phone_sms_type();
    <?php } ?>
</script>

接下來修改后臺配置短信方法,打開項目\module\system\src\system\controller\systemcontroller.php文件,修改savePhoneSmsConfig方法,修改代碼如下:

?
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
   private function savePhoneSmsConfig(array $data$e) {
 
        $phonesmsConfig array();
        $phonesmsConfig['phone_sms_type']       = isset($data['phone_sms_type'])     ? $data['phone_sms_type']           : '';
        $phonesmsConfig['alidayu_sign_name']    = isset($data['alidayu_sign_name'])  ? trim($data['alidayu_sign_name'])    : '';
        $phonesmsConfig['alidayu_app_key']      = isset($data['alidayu_app_key'])    ? trim($data['alidayu_app_key'])    : '';
        $phonesmsConfig['alidayu_app_secret']   = isset($data['alidayu_app_secret']) ? trim($data['alidayu_app_secret']) : '';
 
        $phonesmsConfig['smsbao_sign_name']    = isset($data['smsbao_sign_name'])  ? trim($data['smsbao_sign_name'])    : '';
        $phonesmsConfig['smsbao_app_key']      = isset($data['smsbao_app_key'])    ? trim($data['smsbao_app_key'])    : '';
        $phonesmsConfig['smsbao_app_secret']   = isset($data['smsbao_app_secret']) ? trim($data['smsbao_app_secret']) : '';
 
        $phonesmsConfig['admin_phone']   = isset($data['admin_phone'])  ? trim($data['admin_phone']) : '';
        $phonesmsConfig['admin_submit_order_phone_message']   = isset($data['admin_submit_order_phone_message'])  ? intval($data['admin_submit_order_phone_message']) : '';
        $phonesmsConfig['admin_payment_order_phone_message']  = isset($data['admin_payment_order_phone_message']) ? intval($data['admin_payment_order_phone_message']) : '';
        $phonesmsConfig['admin_finish_order_phone_message']   = isset($data['admin_finish_order_phone_message'])  ? intval($data['admin_finish_order_phone_message']) : '';
        $phonesmsConfig['admin_cancel_order_phone_message']   = isset($data['admin_cancel_order_phone_message'])  ? intval($data['admin_cancel_order_phone_message']) : '';
         $phonesmsConfig['admin_ship_order_phone_message']   = isset($data['admin_ship_order_phone_message'])  ? intval($data['admin_ship_order_phone_message']) : '';
 
        $phonesmsConfig['alidayu_submit_order_template_id']   = isset($data['alidayu_submit_order_template_id'])  ? trim($data['alidayu_submit_order_template_id']) : '';
        $phonesmsConfig['alidayu_payment_order_template_id']  = isset($data['alidayu_payment_order_template_id']) ? trim($data['alidayu_payment_order_template_id']) : '';
        $phonesmsConfig['alidayu_ship_order_template_id']     = isset($data['alidayu_ship_order_template_id'])    ? trim($data['alidayu_ship_order_template_id']) : '';
        $phonesmsConfig['alidayu_finish_order_template_id']   = isset($data['alidayu_finish_order_template_id'])  ? trim($data['alidayu_finish_order_template_id']) : '';
        $phonesmsConfig['alidayu_cancel_order_template_id']   = isset($data['alidayu_cancel_order_template_id'])  ? trim($data['alidayu_cancel_order_template_id']) : '';
 
        $phonesmsConfig['alidayu_phone_captcha_template_id']   = isset($data['alidayu_phone_captcha_template_id'])  ? trim($data['alidayu_phone_captcha_template_id']) : '';
 
 
         $phonesmsConfig['smsbao_submit_order_template_id']   = isset($data['smsbao_submit_order_template_id'])  ? trim($data['smsbao_submit_order_template_id']) : '';
        $phonesmsConfig['smsbao_payment_order_template_id']  = isset($data['smsbao_payment_order_template_id']) ? trim($data['smsbao_payment_order_template_id']) : '';
        $phonesmsConfig['smsbao_ship_order_template_id']     = isset($data['smsbao_ship_order_template_id'])    ? trim($data['smsbao_ship_order_template_id']) : '';
        $phonesmsConfig['smsbao_finish_order_template_id']   = isset($data['smsbao_finish_order_template_id'])  ? trim($data['smsbao_finish_order_template_id']) : '';
        $phonesmsConfig['smsbao_cancel_order_template_id']   = isset($data['smsbao_cancel_order_template_id'])  ? trim($data['smsbao_cancel_order_template_id']) : '';
 
        $phonesmsConfig['smsbao_phone_captcha_template_id']   = isset($data['smsbao_phone_captcha_template_id'])  ? trim($data['smsbao_phone_captcha_template_id']) : '';
 
 
        $e->toFile(DBSHOP_PATH . '/data/moduledata/System/phonesms.ini'array('shop_phone_sms'=>$phonesmsConfig));
    }

最后我們去修改發送代碼,打開項目\module\email\src\email\service\SendPhoneSms.php文件,修改toSendSms方法,修改代碼如下:

?
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
    public function toSendSms($data$user_phone$phone_template=''$user_id '') {
       
        //判斷是否存在,手機是否開啟了短信服務功能,如果不存在未開啟則不進行操作
 
        if (!isset($this->smsConfig['shop_phone_sms']['phone_sms_type']) or $this->smsConfig['shop_phone_sms']['phone_sms_type'] == ''return false;
       
 
 
        $user_phone = !empty($user_phone) ? (is_array($user_phone) ? implode(','$user_phone) : $user_phone) : '';
 
 
 
 
 
        if ($this->smsConfig['shop_phone_sms']['phone_sms_type'] == 'smsbao') {
 
             if(!isset($this->smsConfig['shop_phone_sms'][$phone_template['smsbao']]) or $this->smsConfig['shop_phone_sms'][$phone_template['smsbao']] == ''return false;
 
            if(!empty($this->smsConfig['shop_phone_sms']['admin_phone'])) {
            if($phone_template['smsbao'] == 'smsbao_submit_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_submit_order_phone_message'] == 1)    $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
            if($phone_template['smsbao'] == 'smsbao_payment_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_payment_order_phone_message'] == 1)  $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
 
            if($phone_template['smsbao'] == 'smsbao_ship_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_ship_order_phone_message'] == 1)  $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
            if($phone_template['smsbao'] == 'smsbao_finish_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_finish_order_phone_message'] == 1)    $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
            if($phone_template['smsbao'] == 'smsbao_cancel_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_cancel_order_phone_message'] == 1)    $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
        }
 
             if(empty($user_phone)) return false;
              $user_phone is_array($user_phone) ? implode(','$user_phone) : $user_phone;
 
             $smsJson    $this->createSmsbaoArray($data);
 
             $tempdata $this->smsConfig['shop_phone_sms'][$phone_template['smsbao']];
            foreach ($smsJson as $key => $value 
                {   
                    $tempdata str_replace(trim($key), trim($value), $tempdata);
                };
 
                $content $tempdata;
 
                $content "【".$this->smsConfig['shop_phone_sms']['smsbao_sign_name']."】".$tempdata;
 
            $result array(
                "30"=>"密碼錯誤",
                "40"=>"賬號不存在",
                "41"=>"余額不足",
                "42"=>"帳號過期",
                "43"=>"IP地址限制",
                "50"=>"內容含有敏感詞",
                "51"=>"手機號碼不正確"
                );
 
 
             $url 'http://api.smsbao.com/sms?u='.$this->smsConfig['shop_phone_sms']['smsbao_app_key'].'&p='.md5($this->smsConfig['shop_phone_sms']['smsbao_app_secret']).'&m='.$user_phone.'&c='.$content;
 
             $ret file_get_contents($url);
 
             if ($ret == 0) {
                 return true;
             }else{
                return $result[$ret];
             }
        }else{
 
            if(!isset($this->smsConfig['shop_phone_sms'][$phone_template['alidayu']]) or $this->smsConfig['shop_phone_sms'][$phone_template['alidayu']] == ''return false;
 
            if(!empty($this->smsConfig['shop_phone_sms']['admin_phone'])) {
                if($phone_template['alidayu'] == 'alidayu_submit_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_submit_order_phone_message'] == 1)    $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
                if($phone_template['alidayu'] == 'alidayu_payment_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_payment_order_phone_message'] == 1)  $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
 
                if($phone_template['alidayu'] == 'alidayu_ship_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_ship_order_phone_message'] == 1)  $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
                if($phone_template['alidayu'] == 'alidayu_finish_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_finish_order_phone_message'] == 1)    $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
                if($phone_template['alidayu'] == 'alidayu_cancel_order_template_id' && $this->smsConfig['shop_phone_sms']['admin_cancel_order_phone_message'] == 1)    $user_phone = !empty($user_phone) ? $user_phone.','.$this->smsConfig['shop_phone_sms']['admin_phone'] : $this->smsConfig['shop_phone_sms']['admin_phone'];
            }
            if(empty($user_phone)) return false;
 
            $smsJson    $this->createSmsArray($data);
 
            include(DBSHOP_PATH . '/vendor/alibaba/dayu/TopSdk.php');
            $c new \TopClient();
            $c->appkey    = $this->smsConfig['shop_phone_sms']['alidayu_app_key'];
            $c->secretKey = $this->smsConfig['shop_phone_sms']['alidayu_app_secret'];
 
            $req new \AlibabaAliqinFcSmsNumSendRequest();
            $req->setExtend($user_id);
            $req->setSmsType('normal');
            $req->setSmsFreeSignName($this->smsConfig['shop_phone_sms']['alidayu_sign_name']);
            $req->setSmsParam($smsJson);
            $req->setRecNum($user_phone);
            $req->setSmsTemplateCode($this->smsConfig['shop_phone_sms'][$phone_template]);
            $resp $c->execute($req);
 
        }
 
 
 
    }

到這一步短信寶接口就替換完成了,但是有個問題是發送出來的短信變量沒辦法匹配成功,這是因為短信內容沒有匹配成功,因為發送很多這里就不寫出了,可以根據我給的代碼包進行對比替換, dbshop替換變量文件下載地址。

替換完成后,短信寶短信接口可以正常使用了,我們進行發送測試:

報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,并且免審核了,短信內容3~5秒就可送達。
開源插件

最新更新

電商類

CMS類

微信類

文章標簽