待发短信

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

4001-021-502

工作时间

9:00-18:00

Eyoucms_v1.4.9新增短信宝短信接口

EyouCms是基于TP5.0框架为核心开发的免费+开源的企业内容管理系统,专注企业建站用户需求提供海量各行业模板。小编对这款系统还比较了解,今天就以替换短信接口为例为大家讲解一下如何进行二次开发,使用的短信接口是我们短信宝短信群发平头的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。

1:打开项目:\application\admin\template\system\sms.htm 修改代码26行左右

?
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
 <div class="ncap-form-default">
        <dl class="row">
            <dt class="tit">
                <label for="sms_platform">选择短信平台</label>
            </dt>
            <dd class="opt">
                <select name="sms_platform" id="sms_platform">
                    <option value="1" {if condition="isset($sms.sms_platform) && $sms.sms_platform eq 1"}selected="selected"{/if}>短信宝短信</option>
                </select>
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="smtp_server">发送手机内容</label>
            </dt>
            <dd class="opt">
                [<a href="javascript:void(0);" onclick="sms_tpl_list();">配置模板</a>]
                <p class=""></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <em>*</em>
                <label for="sms_appkey">短信宝账号</label>
            </dt>
            <dd class="opt">
                <input id="sms_appkey" name="sms_appkey" value="{$sms.sms_appkey|default=''}" class="input-txt" type="text"/>
                <p class="notic">短信宝密码</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <em>*</em>
                <label for="sms_secretkey">短信宝账号</label>
            </dt>
            <dd class="opt">
                <input id="sms_secretkey" name="sms_secretkey" value="{$sms.sms_secretkey|default=''}" class="input-txt" type="text"/>
                <p class="notic">短信宝密码</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit"><em>*</em>接收的手机号码</dt>
            <dd class="opt">
                <input value="{$sms.sms_test_mobile|default=''}" name="sms_test_mobile" id="sms_test_mobile" class="input-txt" type="text">
                <input value="测试发送" class="input-btn" onclick="sendMobile();" type="button">
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">短信提醒</dt>
            <dd class="opt">
                <ul class="nc-row ncap-waybill-list">
                    <li style="width: 100%;">
                        <label class="label">
                            <input class="check" type="checkbox" name="sms_shop_order_pay" {if condition="!empty($sms.sms_shop_order_pay)"} value="1" checked="checked" {/if}><span onmouseover="layer_tips = layer.tips('对管理员发送短信提醒', this, {time:100000});" onmouseout="layer.close(layer_tips);">订单付款</span>
                        </label>
                        &nbsp; &nbsp;
                        <label class="label">
                            <input class="check" type="checkbox" name="sms_shop_order_send" {if condition="!empty($sms.sms_shop_order_send)"} value="1" checked="checked" {/if}><span onmouseover="layer_tips = layer.tips('对用户发送短信提醒', this, {time:100000});" onmouseout="layer.close(layer_tips);">订单发货</span>
                        </label>
                    </li>
                </ul>
            </dd>
        </dl>

2:打开项目:\application\admin\template\system\sms_tpl.htm 修改短信模板

?
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
  <div class="flexigrid">
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w10" axis="col0">
                            <div class="tc">&nbsp;</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="w100">
                            <div class="">模板类型</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="w230">
                            <div class="">签名名称</div>
                        </th>
                        <!--<th abbr="article_title" axis="col3" class="w230">-->
                        <!--    <div class="">模板CODE</div>-->
                        <!--</th>-->
                        <th abbr="article_title" axis="col3" class="">
                            <div class="">模板内容</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w50">
                            <div class="tc">启用</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w100">
                            <div class="tc">更新时间</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <td class="sign">
                                <div class="w10 tc">&nbsp;</div>
                            </td>
                            <td class="">
                                <div class="w100">
                                    {$vo.tpl_title}
                                </div>
                            </td>
                            <td class="">
                                <div class="w230">
                                    <input type="text" name="sms_sign" value="{$vo.sms_sign}" onchange="changeTableVal('sms_template', 'tpl_id', '{$vo.tpl_id}', 'sms_sign', this);" style="width: 80%;" title="短信宝短信签名名称,例:易优" placeholder="短信宝短信签名名称,例:易优">
                                </div>
                            </td>
                            <!--<td class="">-->
                            <!--    <div class="w230">-->
                            <!--        <input type="text" name="sms_tpl_code" value="{$vo.sms_tpl_code}" onchange="changeTableVal('sms_template', 'tpl_id', '{$vo.tpl_id}', 'sms_tpl_code', this);" style="width: 80%;" title="短信宝短信模板CODE,例:SMS_123456789" placeholder="短信宝短信模板CODE,例:SMS_123456789">-->
                            <!--    </div>-->
                            <!--</td>-->
                            <td style="width: 100%">
                                <div class="">
                                    <input type="text" name="tpl_content" value="{$vo.tpl_content}" onchange="changeTableVal('sms_template', 'tpl_id', '{$vo.tpl_id}', 'tpl_content', this);" style="width: 94%;" title="短信宝短信模板内容,例:验证码为 ${content} ,请在30分钟内输入验证。" placeholder="短信宝短信模板内容,例:验证码为 ${content} ,请在30分钟内输入验证。">
                                </div>
                            </td>
                            <td class="">
                                <div class="w50 tc">
                                    {eq name="$vo['is_open']" value='1'}
                                        <span class="yes" onClick="changeTableVal('sms_template', 'tpl_id', '{$vo.tpl_id}', 'is_open', this);"><i class="fa fa-check-circle"></i>是</span>
                                    {else /}
                                        <span class="no" onClick="changeTableVal('sms_template', 'tpl_id', '{$vo.tpl_id}', 'is_open', this);"><i class="fa fa-ban"></i>否</span>
                                    {/eq}
                                </div>
                            </td>
                            <td class=""
                                <div class="w100 tc">
                                    {$vo.update_time|MyDate='Y-m-d',###}
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>

3:打开项目:\application\common\logic\SmsLogic.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
     private function sendSmsByAliyun($mobile, $smsSign, $smsParam, $templateCode)
    {
        $accessKeyId = $this->config['sms_appkey'];
        $accessKeySecret = $this->config['sms_secretkey'];
        if (empty($accessKeyId) || empty($accessKeySecret)){
            return array('status' => -1, 'msg' => '请设置短信平台appkey和secretKey');
        }
        $statusStr = array(
            "0" => "短信发送成功",
            "-1" => "参数不全",
            "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!",
            "30" => "密码错误",
            "40" => "账号不存在",
            "41" => "余额不足",
            "42" => "帐户已过期",
            "43" => "IP地址限制",
            "50" => "内容含有敏感词"
        );
        $smsapi = "http://api.smsbao.com/";
        $user = $accessKeyId; //短信平台帐号
        $pass = md5($accessKeySecret); //短信平台密码
        $content= '【'.$smsSign.'】'.$templateCode;//要发送的短信内容
        $phone = $mobile;//要发送短信的手机号码
        $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
        $result =file_get_contents($sendurl) ;
 
 
        //短信发送成功返回True,失败返回false
        if ($result  == '0') {
            return array('status' => 1, 'msg' => $result[$statusStr]);
        else {
            return array('status' => -1, 'msg' =>  $result[$statusStr] . '. Code: ' . $result);
        }
    }

好了经过以上的添加,短信宝Eyoucms_v1.4.9系统增加手机验证就已经安装成功,可以正常使用了

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

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

 
开源插件
文章标签