WhatsnsV6問答系統(tǒng)是一款可以根據(jù)自身業(yè)務(wù)需求快速搭建垂直化領(lǐng)域的php開源問答系統(tǒng),內(nèi)置上百個(gè)功能幫助站長(zhǎng)一分鐘完成PC、Wap、微信端、小程序、APP問答應(yīng)用建設(shè)。小編對(duì)他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進(jìn)行二次開發(fā),我們今天講解的是V6.03版本,使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的短信接口,我們短信寶短信群發(fā)平臺(tái)的接口非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用。
首先打開項(xiàng)目:\application\views\admin\setting_sms.php 修改為短信寶頁面
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
|
<div class= "alert alert-success" ><a target= "_blank" href= "http://www.gjrencai.com/reg" >還沒有注冊(cè)短信寶賬號(hào)!點(diǎn)擊注冊(cè)</a>,價(jià)格合適,穩(wěn)定,個(gè)人可以申請(qǐng)。</div> <form action= "{SITE_URL}index.php?admin_sms/index{$setting['seo_suffix']}" method= "post" > <table class= "table" > <tr class= "header" > <td colspan= "2" >短信參數(shù)設(shè)置</td> </tr> <tbody > <tr> <td class= "altbg1" width= "45%" ><b>短信寶賬號(hào):</b><br><span class= "smalltxt" >填寫短信寶賬號(hào)</span></td> <td class= "altbg2" ><input { if PHP_VERSION<5.6} disabled{/ if } class= "form-control shortinput" type= "text" value= "{if isset($setting['aliyunsmskey'])}$setting['aliyunsmskey']{/if}" name= "aliyunsmskey" /></td> </tr> <tr> <td class= "altbg1" width= "45%" ><b>短信寶密碼:</b><br><span class= "smalltxt" >填寫短信寶密碼</span></td> <td class= "altbg2" ><input { if PHP_VERSION<5.6} disabled{/ if } class= "form-control shortinput" type= "text" value= "{if isset($setting['aliyunsmsaccessSecret'])}$setting['aliyunsmsaccessSecret']{/if}" name= "aliyunsmsaccessSecret" /></td> </tr> <tr> <td class= "altbg1" width= "45%" ><b>注冊(cè)頁面短信驗(yàn)證碼模板</b><br><span class= "smalltxt" >申請(qǐng)注冊(cè)驗(yàn)證碼類型短信模板</span></td> <td class= "altbg2" ><input { if PHP_VERSION<5.6} disabled{/ if } class= "form-control shortinput" type= "text" value= "{if isset($setting['aliyunsmsregtmpid'])}$setting['aliyunsmsregtmpid']{/if}" name= "aliyunsmsregtmpid" /></td> </tr> <tr> <td class= "altbg1" width= "45%" ><b>找回密碼頁面短信驗(yàn)證碼模板</b><br><span class= "smalltxt" >申請(qǐng)找回密碼驗(yàn)證碼類型短信模板</span></td> <td class= "altbg2" ><input { if PHP_VERSION<5.6} disabled{/ if } class= "form-control shortinput" type= "text" value= "{if isset($setting['aliyunsmsfindpwdtmpid'])}$setting['aliyunsmsfindpwdtmpid']{/if}" name= "aliyunsmsfindpwdtmpid" /></td> </tr> <tr> <td class= "altbg1" width= "45%" ><b>短信寶簽名:</b><br><span class= "smalltxt" >簽名需要審核通過才能用</span></td> <td class= "altbg2" ><input { if PHP_VERSION<5.6} disabled{/ if } class= "form-control shortinput" type= "text" value= "{if isset($setting['aliyunsmssign'])}$setting['aliyunsmssign']{/if}" name= "aliyunsmssign" /></td> </tr> </tbody> </table> |
打開項(xiàng)目:application\controllers\Admin\Admin_sms.php 修改set方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
function set(){ if ( null !== $ this ->input->post ( 'submit' )) { checkattack ( $_POST, 'post' ); if ($ this ->input->post ( 'smscanuse' ) == 'on' ) { $ this ->setting [ 'smscanuse' ] = 1; } else { $ this ->setting [ 'smscanuse' ] = 0; } $smsplatform=$ this ->input->post ( 'allow_smsplatform' ); if (!$smsplatform){ $message = '請(qǐng)選擇默認(rèn)的短信平臺(tái)!' ; } else { $ this ->setting [ 'allow_smsplatform' ] = $smsplatform; $ this ->setting_model->update ( $ this ->setting ); $message = '短信設(shè)置更新成功!' ; } } include template ( 'setting_sms' , 'admin' ); } |
打開項(xiàng)目:system\helpers\public_helper.php 修改為短信寶短信發(fā)送方法
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
|
function aliyunsms($phonenum, $tmpcode, $code) { global $setting; // AlibabaCloud::accessKeyClient ( $setting ['aliyunsmskey'], $setting ['aliyunsmsaccessSecret'] )->regionId ( 'cn-hangzhou' )->asDefaultClient (); //修改短信寶短信插件 $message = array (); $user = $setting [ 'aliyunsmskey' ]; //短信平臺(tái)帳號(hào) $pass = md5($setting [ 'aliyunsmsaccessSecret' ]); //短信平臺(tái)密碼 $content = str_replace( '{code}' ,$code,$tmpcode); $content= '【' .$setting [ 'aliyunsmssign' ]. '】' .$content; //要發(fā)送的短信內(nèi)容 $phone = $phonenum; //要發(fā)送短信的手機(jī)號(hào)碼 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); // $result =file_get_contents($sendurl) ; $result = 0; if ($result == 0){ $message [ 'errorcode' ] = 0; // 狀態(tài)為0,說明短信發(fā)送成功 $message [ 'Message' ] = 'OK' ; } else { $message [ 'errorcode' ] = 1; $message [ 'Message' ] = '短信發(fā)送失敗' ; } return $message; } |
經(jīng)過上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。
報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開發(fā)好完整的WhatsnsV6.03問答系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類