待发短信

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

4001-021-502

工作时间

9:00-21:00

ShopXO v1.9.1 商城系统新增短信宝短信接口

ShopXO是国内领先的商城系统提供商,为企业提供php商城系统、微信商城、小程序。小编发现ShopXO更新到1.9.1版本,就以替换短信接口为例告诉大家如何进行二次开发,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用

1:打开项目:\application\admin\view\default\sms\nav.html文件 替换以下代码

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<ul class="am-nav am-nav-pills table-nav m-b-10">
    <li {{if $nav_type eq 'sms'}}class="am-active"{{/if}} data-type="sms">
        <a href="{{:MyUrl('admin/sms/index', ['type'=>'sms'])}}">短信设置</a>
    </li>
    <li {{if $nav_type eq 'message'}}class="am-active"{{/if}} data-type="message">
        <a href="{{:MyUrl('admin/sms/index', ['type'=>'message'])}}">消息模板</a>
    </li>
</ul>
 
 
<div class="am-alert am-alert-warning am-radius" data-am-alert>
    <button type="button" class="am-close">&times;</button>
    <p class="fs-12">还没有短信宝帐号?请<a href="http://www.smsbao.com/reg" style="color:red">点击注册</a></p>
</div>

2:打开项目:\application\admin\view\default\sms\index.html 替换为短信宝页面

?

2

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
{{include file="public/header" /}}
 
 
<!-- right content start  -->
<div class="content-right">
    <div class="content">
        <!-- table nav start -->
        {{include file="sms/nav"" /}}
        <!-- table nav end -->
        
        <!-- form start -->
        <form class="am-form form-validation view-save" action="{{:MyUrl('admin/sms/save')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('admin/sms/index', ['type'=>'sms'])}}">
            <div class="am-form-group">
                <label>短信宝账号<span class="am-form-group-label-tips">填写短信宝账号</span></label>
                <input type="text" name="{{$data.common_sms_apikey.only_tag}}" placeholder="{{$data.common_sms_apikey.name}}" data-validation-message="{{$data.common_sms_apikey.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_sms_apikey.value}}"{{/if}} />
            </div>
            <div class="am-form-group">
                <label>短信宝密码<span class="am-form-group-label-tips">填写短信宝密码</span></label>
                <input type="text" name="{{$data.common_sms_apisecret.only_tag}}" placeholder="{{$data.common_sms_apisecret.name}}" data-validation-message="{{$data.common_sms_apisecret.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_sms_apisecret.value}}"{{/if}} />
            </div>
            <div class="am-form-group">
                <label>{{$data.common_sms_sign.name}}<span class="am-form-group-label-tips">{{$data.common_sms_sign.describe}}</span></label>
                <input type="text" name="{{$data.common_sms_sign.only_tag}}" placeholder="{{$data.common_sms_sign.name}}" data-validation-message="{{$data.common_sms_sign.error_tips}}" class="am-radius" maxlength="16" {{if !empty($data)}}value="{{$data.common_sms_sign.value}}"{{/if}} />
            </div>
            <div class="am-form-group am-form-group-refreshing">
                <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
            </div>
        </form>
        <!-- form end -->
    </div>
</div>
<!-- right content end  -->
        
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

3:最后打开项目:\extend\base\Sms.php文件,替换SendCode方法。

?
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
public function SendCode($mobile, $code, $template_code) {
    // 是否频繁操作
    if(!$this->IntervalTimeCheck())
    {
        $this->error = '防止造成骚扰,请勿频繁发送';
        return false;
    }
    $content = str_replace('code',$code,$template_code);
    $url = 'http://api.smsbao.com/sms?u='.$this->accessKeyId.'&p='.md5($this->accessKeySecret).'&m='.$mobile.'&c=【'.$this->signName.'】'.$content;
 
 
    $ch = curl_init ();
    curl_setopt ( $ch, CURLOPT_URL, $url );
    curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
    curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt ( $ch, CURLOPT_TIMEOUT, 10 );
    $result = curl_exec ( $ch );
    curl_close ( $ch );
    if ($result != 0) {
        $this->error = $result;
        return false;
    }
 
 
    // 种session
    $this->KindofSession($code);
 
 
    return true;

经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。

另外:我们已经开发好完整的ShopXO v1.9.1系统短信宝插件,点击此链接 下载及查看安装流程。

开源插件

最新更新

电商类

CMS类

微信类

文章标签