待发短信

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

4001-021-502

工作时间

9:00-21:00

PHPSHE商城短信接口替换

PHPSHE B2C商城系统是基于 php+mysql 开发语言,完全面向对象的技术架构设计开发。它是一款开源软件,二次开发比较方便,今天小编就以替换短信接口为例为大家讲解一下如何二次开发,我们今天讲解的是1.6版本的,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。

进行接口替换我们首先进行修改短信配置界面,打开项目\template\default\admin\setting_sms.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
<!--{include(pe_tpl('header.html'));}-->
<div class="right">
        <!--{include(pe_tpl('setting_menu.html'));}-->
        <form method="post" id="form">
        <div class="right_main">
                <div class="tixing">
                        <p><span class="cred">[注]</span> 管理员手机号:用于接收短信通知,多个用“,”隔开</p>
                </div>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="wenzhang mat20 mab20">
                <tr>
                        <td align="right" width="150">短信宝帐号:</td>
                        <td><input type="text" name="info[sms_key]" value="{$info['sms_key']['setting_value']}" class="inputall input300" /> 还没有账号? <a href="https://www.smsbao.com/reg" style="color: red;">请点击注册</a></td>
                </tr>
                <tr>
                        <td align="right" width="150">短信宝密码:</td>
                        <td><input type="text" name="info[sms_password]" value="{$info['sms_password']['setting_value']}" class="inputall input300" /></td>
                </tr>
                <tr>
                        <td align="right">短信签名:</td>
                        <td><input type="text" name="info[sms_sign]" value="{$info['sms_sign']['setting_value']}" class="inputall input300" /> <span class="c999">(如:短信宝)</span></td>
                </tr>
                <tr>
                        <td align="right">管理员手机号:</td>
                        <td>
                                <input type="text" name="info[sms_admin]" value="{$info['sms_admin']['setting_value']}" class="inputall input300" />
                                <a href="javascript:;" class="admin_btn mal10" id="sms_test" />发送测试短信</a>
                                <span class="c888">(用于接收订单通知,多个用“,”隔开)</span>        
                        </td>
                </tr>
                </table>
        </div>
        <div class="right_main2">
                <div class="now2"><p>邮箱设置</p></div>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="wenzhang mat20">
                <tr>
                        <td align="right" width="150">SMTP地址:</td>
                        <td><input type="text" name="info[email_smtp]" value="{$info['email_smtp']['setting_value']}" class="inputall input200" /> <span class="c888">(例:smtp.qq.com)</span></td>
                </tr>
                <tr>
                        <td align="right">SSL协议:</td>
                        <td>
                                <!--{foreach(array(1=>'启用', 0=>'停用') as $k=>$v):}-->
                                <!--{$checked = $info['email_ssl']['setting_value'] == $k ? 'checked="checked"' : ''}-->
                                <label class="mar20"><input type="radio" name="info[email_ssl]" value="{$k}" class="inputfix" {$checked} /> {$v}</label>
                                <!--{endforeach;}-->
                        </td>
                </tr>
                <tr>
                        <td align="right">SMTP端口:</td>
                        <td><input type="text" name="info[email_port]" value="{$info['email_port']['setting_value']}" class="inputall input200" /> <span class="c888">(例:25)</span></td>
                </tr>
                <tr>
                        <td align="right">发件人邮箱:</td>
                        <td><input type="text" name="info[email_name]" value="{$info['email_name']['setting_value']}" class="inputall input200" /> <span class="c888">(例:123456@qq.com)</span></td>
                </tr>
                <tr>
                        <td align="right">发件人密码:</td>
                        <td><input type="text" name="info[email_pw]" value="{$info['email_pw']['setting_value']}" class="inputall input200" /></td>
                </tr>
                <tr>
                        <td align="right">发件人姓名:</td>
                        <td><input type="text" name="info[email_nname]" value="{$info['email_nname']['setting_value']}" class="inputall input200" /> <span class="c888">(例:简好网络)</span></td>
                </tr>
                <tr>
                        <td align="right">管理员邮箱:</td>
                        <td>
                                <input type="text" name="info[email_admin]" value="{$info['email_admin']['setting_value']}" class="inputall input350" />
                                <a href="javascript:;" class="admin_btn mal10" id="email_test" />发送测试邮件</a>
                                <span class="c888">(用于接收邮件通知,多个用“,”隔开)</span>        
                        </td>
                </tr>
                <tr>
                        <td></td>
                        <td>
                                <input type="hidden" name="pesubmit" />
                                <input type="hidden" name="pe_token" value="{$pe_token}" />
                                <input type="submit" value="提 交" class="tjbtn" />
                        </td>
                </tr>
                </table>
        </div>
        </form>
</div>
<script type="text/javascript">
$(function(){
        $("#sms_test").click(function(){
                $(this).attr("href", "admin.php?mod=setting&act=sms_test&user="+$(":input[name='info[sms_admin]']").val()+"&token={$pe_token}");
        })
        $("#email_test").click(function(){
                $(this).attr("href", "admin.php?mod=setting&act=email_test&user="+$(":input[name='info[email_admin]']").val()+"&token={$pe_token}")
        })
})
</script>
<!--{include(pe_tpl('footer.html'));}-->

经过上面的替换,后台显示页面就是短信宝的了,接下来我们去修改保存配置信息的文件,打开项目\module\admin\setting.php,我们找到case sms,修改为以下代码:

?
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
   //#####################@ 短信设置 @#####################//
        case 'sms':
                if (isset($_p_pesubmit)) {
                        pe_token_match();
                        $sql "update `".dbpre."setting` set `setting_value` = case `setting_key`
                                when 'sms_key' then '".pe_dbhold($_p_info['sms_key'])."'
                                when 'sms_password' then '".pe_dbhold($_p_info['sms_password'])."'
                                when 'sms_sign' then '".pe_dbhold($_p_info['sms_sign'])."'
                                when 'sms_admin' then '".pe_dbhold($_p_info['sms_admin'])."'
                                when 'email_smtp' then '".pe_dbhold($_p_info['email_smtp'])."'
                                when 'email_ssl' then '".pe_dbhold($_p_info['email_ssl'])."'
                                when 'email_port' then '".pe_dbhold($_p_info['email_port'])."'
                                when 'email_name' then '".pe_dbhold($_p_info['email_name'])."'
                                when 'email_pw' then '".pe_dbhold($_p_info['email_pw'])."'
                                when 'email_nname' then '".pe_dbhold($_p_info['email_nname'])."'
                                when 'email_admin' then '".pe_dbhold($_p_info['email_admin'])."' else `setting_value` end";
                        if ($db->sql_update($sql)) {
                                cache_write('setting');
                                pe_success('设置成功!');
                        }
                        else {
                                pe_error('设置失败...');
                        }
                }
                $info $db->index('setting_key')->pe_selectall('setting');        
                $seo = pe_seo($menutitle='短信设置''''''admin');
                include(pe_tpl('setting_sms.html'));
        break;

短信配置文件修改好了,我们去修改接口发送文件,打开项目\hook\qunfa.hook.php,修改quanfa_sms方法,修改代码为:

?
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
//发送短信
function qunfa_sms($phone$text$qunfa_id = 0) {
        global $db$cache_setting;
 
        $url 'http://api.smsbao.com/sms?u='.$cache_setting['sms_key'].'&p='.md5($cache_setting['sms_password']).'&m='.$phone.'&c=【'.$cache_setting['sms_sign'].'】'.$text;
 
        $result file_get_contents($url);
        //更新或插入发送日志
        $sql_set['noticelog_stime'] = time();
        if ($result == 0) {
                $sql_set['noticelog_state'] = 'success';                        
        }
        else {
                $sql_set['noticelog_state'] = 'fail';                        
                $sql_set['noticelog_error'] = $result;
        }
        if ($qunfa_id) {
                $db->pe_update('noticelog'array('noticelog_id'=>$qunfa_id), pe_dbhold($sql_set));
        }
        else {
                $sql_set['noticelog_type'] = 'sms';
                $sql_set['noticelog_user'] = $phone;                        
                $sql_set['noticelog_name'] = '';
                $sql_set['noticelog_text'] = $text;
                $sql_set['noticelog_atime'] = time();
                $db->pe_insert('noticelog', pe_dbhold($sql_set));
        }
        return $result;
}

最后我们增加一个数据库字段,代码为:

?
1
2
3
4
5
6
7
8
9
10
11
<?php
 
/**
 * msbao.php
 * 短信宝插件安装,增加密码字段
 */
include('./common.php');
$sql_set['setting_key'] = 'sms_password'
$sql_set['setting_value'] = ''
$db->pe_insert('setting',$sql_set);
echo '短信宝插件安装成功,请删除smsbao.php文件';

好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。

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

最新更新

电商类

CMS类

微信类

文章标签