人人商城開源框架,一款針對人人商城的一個框架搭建程序,幫助您輕松搭建想要的人人商城系統。今天小編就以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.gjrencai.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秒就可送達。
另外:我們已經開發好完整的人人商城系統短信寶插件,點擊此鏈接 下載及查看安裝流程
最新更新
電商類
CMS類
微信類