微擎是一款免費開源的公眾平臺管理系統,基于web2.0技術架構,他有很多的擴展模塊,二次開發也非常方便,小編對于這套系統還是比較了解的,今天小編就以微擎_1.8版本的替換短信接口為例告訴大家如何進行二次開發,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先我們打開項目:\web\themes\default\system\user-setting.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
|
{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.gjrencai.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} |
接著在項目:\web\themes\default\system\user-setting-header.html文件中添加以下代碼
1
|
< li {if $do == 'sms'} class = "active" {/if}>< a href="{php echo url('system/usersetting', array('do' => 'sms'))}">短信配置</ a ></ li > |
接著打開項目:\web\source\system\usersetting.ctrl.php 文件替換8~28行代碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
$dos = array ( 'login' , 'binding' , 'sms' ); $do = in_array( $do , $dos ) ? $do : 'login' ; $settings = $_W [ 'setting' ][ 'copyright' ]; if ( empty ( $settings ) || ! is_array ( $settings )) { $settings = array (); } else { $settings [ 'slides' ] = iunserializer( $settings [ 'slides' ]); } 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' ); } } |
最后我們打開項目:\framework\model\cloud.mod.php 文件,替換cloud_sms_send方法
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
|
function cloud_sms_send( $mobile , $content , $postdata = array (), $custom_sign = '' ) { global $_W ; if (!preg_match( '/^1\d{10}$/' , $mobile ) || empty ( $content )) { return error(1, '發送短信失敗, 原因: 手機號錯誤或內容為空.' ); } if ( empty ( $_W [ 'uniacid' ])) { $sms_info = cloud_sms_info(); $balance = empty ( $sms_info [ 'sms_count' ]) ? 0 : $sms_info [ 'sms_count' ]; if (! empty ( $custom_sign )) { $sign = $custom_sign ; } } else { $row = pdo_get( 'uni_settings' , array ( 'uniacid' => $_W [ 'uniacid' ]), array ( 'notify' )); $row [ 'notify' ] = @iunserializer( $row [ 'notify' ]); $config = $row [ 'notify' ][ 'sms' ]; $balance = intval ( $config [ 'balance' ]); $sign = $config [ 'signature' ]; } if ( empty ( $sign )) { $sign = '短信寶' ; } //判斷剩余條數 if ( $balance <1){ return error(-1, '短信發送失敗, 原因:余額不足' ); } //短信寶賬號 // $smsbao_info=pdo_get('uni_settings' , array('uniacid' => $_W['uniacid']), array('copyright')); //$smsbao_info=setting_load($key = 'copyright'); $sms_param [ 'u' ]= $_W [ 'setting' ][ 'copyright' ][ 'sms_name' ]; $sms_param [ 'p' ]=md5( $_W [ 'setting' ][ 'copyright' ][ 'sms_password' ]); $sms_param [ 'm' ]= $mobile ; $sms_param [ 'c' ]= "【" . $_W [ 'setting' ][ 'copyright' ][ 'sms_sign' ]. "】" . $content ; $statusStr = array ( "0" => "短信發送成功" , "-1" => "參數不全" , "-2" => "服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!" , "30" => "密碼錯誤" , "40" => "賬號不存在" , "41" => "余額不足" , "42" => "帳戶已過期" , "43" => "IP地址限制" , "50" => "內容含有敏感詞" ); if (trim( $response )!= '0' ) { return error( $response , '短信發送失敗, 原因:' . $statusStr [ $response ]); } if (trim( $response )== '0' ) { if (! empty ( $_W [ 'uniacid' ])) { $row [ 'notify' ][ 'sms' ][ 'balance' ] = $row [ 'notify' ][ 'sms' ][ 'balance' ] - 1; if ( $row [ 'notify' ][ 'sms' ][ 'balance' ] < 0) { $row [ 'notify' ][ 'sms' ][ 'balance' ] = 0; } pdo_update( 'uni_settings' , array ( 'notify' => iserializer( $row [ 'notify' ])), array ( 'uniacid' => $_W [ 'uniacid' ])); uni_setting_save( 'notify' , $row [ 'notify' ]); } } return true; } |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的微擎系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類