人人商城开源框架,一款针对人人商城的一个框架搭建程序,帮助您轻松搭建想要的人人商城系统。今天小编就以3.10.4版本替换短信接口为例,一步一步的手把手教大家开发,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
首先打开项目:\template\web\sysset\sms\set.html文件,替换22行左右的代码:
|
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
|
<div class="alert alert-info"> <h4 style="font-weight: 500">短信提醒配置说明</h4> </div><div class="form-group-title">短信宝<kbd>推荐</kbd><small style="padding-left:10px;"><a target="_blank" href="http://www.smsbao.com">立即申请</a></small> <span class="pull-right"> <input type="hidden" value="<?php echo $item['smsbao'];?>" name="smsbao" /> <input class="js-switch small" type="checkbox" <?php if(!empty($item['smsbao'])) {?>checked<?php }?>/> </span> </div> <div class=" sms-smsbao" style="<?php if(empty($item['smsbao'])) { ?>display: none;<?php } ?>"> <div class="form-group"> <label class="col-sm-2 control-label must">短信宝帐号</label> <div class="col-sm-9 col-xs-12"> <input type="text" name="smsbao_key" class="form-control valid" value="<?php echo $item['smsbao_key'];?>" data-rule-required="true"> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label must">短信宝密码</label> <div class="col-sm-9 col-xs-12"> <input type="text" name="smsbao_secret" class="form-control valid" value="<?php echo $item['smsbao_secret'];?>" data-rule-required="true"> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label must">短信宝签名</label> <div class="col-sm-9 col-xs-12"> <input type="text" name="smsbao_sign" class="form-control valid" value="<?php echo $item['smsbao_sign'];?>" data-rule-required="true"> </div> </div> </div> |
接着打开项目:\template\web\sysset\sms\temp\post.html文件,替换44行左右代码:
|
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
|
<div class="form-group"> <label class="col-sm-2 control-label {ifp 'sysset.sms.temp.edit'}must{/if}">服务商</label> <div class="col-sm-9 col-xs-12">{ife 'sysset.sms.temp' $item} {if !empty($smsset['juhe']) || (!empty($item) && $item['type']=='juhe')} <label class="radio-inline"><input type="radio" class="sms-type" data-template="1" name="type" value="juhe" {if $item['type']=='juhe' || empty($item)}checked{/if} {if !empty($item['type'])}disabled{/if}> 聚合数据</label>{/if} {if !empty($smsset['dayu']) || (!empty($item) && $item['type']=='dayu')}<label class="radio-inline"><input type="radio" class="sms-type" data-template="1" name="type" value="dayu" {if $item['type']=='dayu'} checked{/if} {if !empty($item['type'])}disabled{/if}> 阿里大于(老用户)</label>{/if} {if !empty($smsset['aliyun']) || (!empty($item) && $item['type']=='aliyun')} <label class="radio-inline"><input type="radio" class="sms-type" data-template="1" name="type" value="aliyun" {if $item['type']=='aliyun'} checked{/if} {if !empty($item['type'])}disabled{/if}> 阿里云短信</label> {/if} {if !empty($smsset['emay']) || (!empty($item) && $item['type']=='emay')}<label class="radio-inline"><input type="radio" class="sms-type" data-template="0" name="type" value="emay" {if $item['type']=='emay'} checked{/if} {if !empty($item['type'])}disabled{/if}> 亿美软通</label> {/if} {if !empty($smsset['smsbao']) || (!empty($item) && $item['type']=='smsbao')} <label class="radio-inline"><input type="radio" class="sms-type" data-template="0" name="type" value="smsbao" {if $item['type']=='smsbao'} checked {/if} {if !empty($item['type'])}disabled{/if}>短信宝</label> {/if} <div class="help-block">注意:选择短信服务商请先至 <a href="{php echo webUrl('sysset/sms/set')}" target="_blank">短信接口设置</a> 页面设置好短信服务商的接口信息。(<span class="text-danger">保存后不可修改</span> )</div> } {else} <div class='form-control-static'>{if $item['type']=='juhe'}聚合数据{elseif $item['type']=='dayu'}阿里大于{elseif $item['type']=='emay'}亿美软通{elseif $item['type']=='smsbao'}短信宝{/if}</div> {/if} </div> </div> |
接着打开项目:\core\com\sms.php文件,在48行左右增加以下代码:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
else if($template['type'] == 'smsbao'){ $request = array( '30' => '密码错误', '40' => '账号不存在', '41' => '余额不足', '42' => '账号过期', '43' => 'IP地址限制', '50' => '内容含有敏感词', '51' => '手机号码不正确' ); $url = 'http://api.smsbao.com/sms?u='.$smsset['smsbao_key'].'&p='.md5($smsset['smsbao_secret']).'&m='.$mobile.'&c=【'.$smsset['smsbao_sign'].'】'.$params; $res = file_get_contents($url); if ($res !=0) { return array('status'=>$res,'message'=>$request[$res]); } } |
接着在209行左右添加以下代码:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
else if($template['type'] == 'smsbao'){ if (empty($smsset['smsbao'])) { return array('status' => 0, 'message' => '未开启短信宝!'); } if (empty($smsset['smsbao_key'])) { return array('status' => 0, 'message' => '未填写短信宝帐号!'); } if (empty($smsset['smsbao_secret'])) { return array('status' => 0, 'message' => '未填写短信宝密码!'); } if (empty($smsset['smsbao_sign'])) { return array('status' => 0, 'message' => '未填写短信宝签名!'); } } |
最后在319行左右添加以下代码:
|
1
2
3
4
5
6
7
|
if ($type == 'smsbao') { $template = $template['content']; foreach ($data as $key => $value) { $template = str_replace('{'.$key.'}', $value, $template); } $result = $template; } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:

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

