微擎是一款免费开源的公众平台管理系统,基于web2.0技术架构,他有很多的扩展模块,二次开发也非常方便,小编最近发现很多客户再寻找微擎2.0的短信插件,今天小编就以微擎2.0版本的替换短信接口为例告诉大家如何进行二次开发,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用
1:打开项目:\web\themes\default\system\user-setting-header.html 修改大致在第6行代码
|
1
2
3
4
|
<li {if $action == 'registerset' && $do == 'display'}class="active"{/if}><a href="{php echo url('user/registerset/display');}">登录/注册设置</a></li><li {if $action == 'thirdlogin'}class="active"{/if}><a href="{php echo url('system/thirdlogin')}">第三方配置</a></li><li {if $do == 'clerk'}class="active"{/if}><a href="{php echo url('user/registerset/clerk')}">应用操作员登录/注册设置</a></li><li {if $do == 'sms'}class="active"{/if}><a href="{php echo url('system/usersetting', array('do' => 'sms'))}">短信配置</a></li> |
2:打开项目:\web\themes\default\system\user-setting.html 在73行左右新增短信宝接口页面
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
{if $do == 'sms'}<div id="sms"> <div class="form-group"> <label class="col-sm-2 control-label" style="text-align:left;">短信宝账号</label> <div class="col-sm-8"> <input type="text" name="sms_name" class="form-control" value="{$settings['sms_name']}" /> <span class="help-block">没有短信宝账号?点击<a class="btn btn-primary span3" target="_blank" href="http://www.smsbao.com">免费注册</a></span> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label" style="text-align:left;">短信宝密码</label> <div class="col-sm-8"> <input type="password" name="sms_password" class="form-control" value="{$settings['sms_password']}" /> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label" style="text-align:left;">短信签名</label> <div class="col-sm-8"> <input type="text" name="sms_sign" class="form-control" value="{$settings['sms_sign']}" /> </div> </div></div>{/if} |
3:打开项目:\web\source\utility\verifycode.ctrl.php 修改下send_code 方法
|
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
|
if ($do == 'send_code') { $verifycode_table = table('uni_verifycode'); $row = $verifycode_table->getByReceiverVerifycode($_W['uniacid'], $receiver, ''); $record = array(); $code = random(6, true); if(!empty($row)) { $imagecode = intval($_GPC['imagecode']); $failed_count = table('uni_verifycode')->getFailedCountByReceiver($receiver); if ($failed_count >= 3) { if (empty($imagecode)) { iajax(-3, '请输入图形验证码!'); } if (!checkcaptcha($imagecode)) { iajax(-1, '图形验证码错误!'); } } if($row['total'] >= 5) { iajax(-1, '您的操作过于频繁,请稍后再试'); } $record['total'] = $row['total'] + 1; } else { $record['uniacid'] = $_W['uniacid']; $record['receiver'] = $receiver; $record['total'] = 1; } $record['verifycode'] = $code; $record['createtime'] = TIMESTAMP; if(!empty($row)) { pdo_update('uni_verifycode', $record, array('id' => $row['id'])); } else { pdo_insert('uni_verifycode', $record); } if($receiver_type == 'email') { load()->func('communication'); $content = "您的邮箱验证码为: {$code} 您正在使用{$uniacid_arr['name']}相关功能, 需要你进行身份确认."; $result = ihttp_email($receiver, "{$uniacid_arr['name']}身份确认验证码", $content); } else { load()->model('cloud'); $r = cloud_prepare(); if(is_error($r)) { iajax(-1, $r['message']); } $setting = uni_setting($_W['uniacid'], 'notify'); //$postdata = array('verify_code' => $code, 'module' => '找回密码'); $content = "您的短信验证码为: {$code} 您正在使用{$uniacid_arr['name']}相关功能, 需要你进行身份确认,请不要告诉他人 "; $result = cloud_sms_send($receiver, $content, array(), $custom_sign); } if (is_error($result)) { iajax(-1, $result['message']); } iajax(0, '短信发送成功!');} |
5:打开项目:\web\source\system\usersetting.ctrl.php 在16行左右新增短信配置
|
1
2
3
4
5
6
7
8
9
|
if ($do == 'sms') { $_W['page']['title'] = '短信配置'; if (checksubmit('submit')) { $settings['sms_name'] = $_GPC['sms_name']; $settings['sms_password'] = $_GPC['sms_password']; $settings['sms_sign'] = $_GPC['sms_sign']; setting_save($settings, 'copyright'); itoast('更新设置成功!', '', 'success'); } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的微擎V_2.0系统短信宝插件,点击此链接 下载及查看安装流程。

