待发短信

在线客服
产品支持 短信宝客服
合作渠道 渠道合作
服务咨询

4001-021-502

工作时间

9:00-21:00

SHOPNR本地电商系统短信接口替换

SHOPNR本地电商系统是一款简单的外卖系统,他是基于PHP+MYSQL开发的,对于后期维护和二次开发比较容易,小编对这款系统还是比较了解的,今天小编就以短信接口替换为例,为大家讲解一下如何进行二次开发,我们今天讲解的是2.1.5版本,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。

我们首先修改后台显示界面,打开项目\App\shopadmin\Tpl\Config\index.html 文件,修改233~275左右代码,修改为:

?
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
<div class="am-panel am-panel-default">
        <div class="am-panel-hd">短信接口</div>
        <div class="am-panel-bd">
                <div class="am-form-group">
                        <label class="am-form-label inputname">短信宝帐号:</label>
                        <div class="inputbox">
                                <input type="text"  name="sms_account" id="doc-ipt-name-1" value="{$site.sms_account}">
                                <small>还没有帐号?请点击<a href="http://www.smsbao.com/reg">注册</a></small>
                        </div>
                </div>
                <div class="am-form-group">
                        <label class="am-form-label inputname">短信宝密码:</label>
                        <div class="inputbox">
                                <input type="password"  name="sms_password" id="doc-ipt-name-1" value="{$site.sms_password}">
                        </div>
                </div>
                <div class="am-form-group">
                        <label class="am-form-label inputname">短信验证:</label>
                        <div class="inputbox" style="margin-top: 10px;">
                                <input type="radio"  name="is_sms_validate" value='1' <eq name="site.is_sms_validate" value="1">checked="checked"</eq> >&nbsp;&nbsp;开启&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="radio"  name="is_sms_validate" value='0' <eq name="site.is_sms_validate" value="0">checked="checked"</eq>>&nbsp;&nbsp;关闭<br />
                                <small>用户注册的时候,必须进行短信验证;必须开通短信验证,用户才能找回密码</small>
                        </div>
                </div>
                <div class="am-form-group">
                        <label class="am-form-label inputname">短信订单:</label>
                        <div class="inputbox" style="margin-top: 10px;">
                                <input type="radio"  name="is_sms_order" value='1' <eq name="site.is_sms_order" value="1">checked="checked"</eq>>&nbsp;&nbsp;开启&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="radio"  name="is_sms_order" value='0' <eq name="site.is_sms_order" value="0">checked="checked"</eq>>&nbsp;&nbsp;关闭<br />
                                <small>用户下单,会给商家和买家发送短信通知</small>
                        </div>
                </div>
                <div class="am-form-group">
                        <label class="am-form-label inputname">账户短信:</label>
                        <div class="inputbox" style="margin-top: 10px;">
                                <input type="radio"  name="is_sms_money" value='1' <eq name="site.is_sms_money" value="1">checked="checked"</eq>>&nbsp;&nbsp;开启&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="radio"  name="is_sms_money" value='0' <eq name="site.is_sms_money" value="0">checked="checked"</eq>>&nbsp;&nbsp;关闭<br />
                                <small>用户账号积分或者金额变动,会给会员发送短信通知</small>
                        </div>
                </div>
                <div class="am-form-group">
                        <label class="am-form-label inputname">接单手机号:</label>
                        <div class="inputbox">
                                <input type="text"  name="get_tel" id="doc-ipt-name-1" value="{$site.get_tel}">
                                <small>必须填写手机号,用来接收新订单的短信通知。</small>
                        </div>
                </div>
                <div class="am-form-group">
                        <label class="am-form-label inputname">短信签名:</label>
                        <div class="inputbox">
                                <input type="text"  name="sms_sign" id="doc-ipt-name-1" value="{$site.sms_sign}">
                                <small>必须,如“【短信宝】” 3-8个字。</small>
                        </div>
                </div>
                <div class="am-form-group">
                        <label class="am-form-label inputname">&nbsp;</label>
                        <div class="inputbox"><button type="submit" class="am-btn am-btn-primary" >保存修改</button></div>
                </div>
        </div>
</div>

接下来我们修改调用短信接口的文件,打开项目\Common\common.php文件,修改 send_message 方法, 代码如下:

?
1
2
3
4
5
6
7
 //短信发送
        function send_message($tel,$content){
 
                import('ORG.Util.smsbao.smsbao');
                $sendObj new smsbao(C("sms_account"),C("sms_password"));
        $resultObj $sendObj ->sendMessage($tel,C('sms_sign').$content);
        }

最后我们添加短信宝接口,打开项目\Framework\Library\ORG\Util 我们在Util下创建smsbao文件夹,在smsbao下创建smsbao.class.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
<?php
 
/**
  php 环境须装有curl模块和json模块才能正常使用该程序, 本页面使用utf-8编码,短信内容为utf-8编码
**/
 
 
/**
* 短信宝短信平台
*/
class smsbao 
{
 
        public function __construct($username,$pass)
        {
                $this->u = $username;
                $this->p = md5($pass);
        }
 
 
        function sendMessage($mobile,$content)
        {
                $url 'http://api.smsbao.com/sms?u='.$this->u.'&p='.$this->p.'&m='.$mobile.'&c='.$content;
                if (function_exists('file_get_contents')) {
                        $ret file_get_contents($url);
                }else{
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            if (!empty($data)) {
                    curl_setopt($curl, CURLOPT_POST, 1);
                    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                }
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                $ret = curl_exec($curl);
                curl_close($curl);
                 return $info;
                }
        }
}

好了,经过以上的替换,短信宝的短信平台已经替换成功了,我们去进行发送测试:

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
开源插件

最新更新

电商类

CMS类

微信类

文章标签