WhatsnsV6問答系統是一款可以根據自身業務需求快速搭建垂直化領域的php開源問答系統,內置上百個功能幫助站長一分鐘完成PC、Wap、微信端、小程序、APP問答應用建設。小編對他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發,我們今天講解的是V6.03版本,使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺的接口非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先打開項目:\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" >還沒有注冊短信寶賬號!點擊注冊</a>,價格合適,穩定,個人可以申請。</div> <form action= "{SITE_URL}index.php?admin_sms/index{$setting['seo_suffix']}" method= "post" > <table class= "table" > <tr class= "header" > <td colspan= "2" >短信參數設置</td> </tr> <tbody > <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['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>注冊頁面短信驗證碼模板</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['aliyunsmsregtmpid'])}$setting['aliyunsmsregtmpid']{/if}" name= "aliyunsmsregtmpid" /></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['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> |
打開項目: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 = '請選擇默認的短信平臺!' ; } else { $ this ->setting [ 'allow_smsplatform' ] = $smsplatform; $ this ->setting_model->update ( $ this ->setting ); $message = '短信設置更新成功!' ; } } include template ( 'setting_sms' , 'admin' ); } |
打開項目:system\helpers\public_helper.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
|
function aliyunsms($phonenum, $tmpcode, $code) { global $setting; // AlibabaCloud::accessKeyClient ( $setting ['aliyunsmskey'], $setting ['aliyunsmsaccessSecret'] )->regionId ( 'cn-hangzhou' )->asDefaultClient (); //修改短信寶短信插件 $message = array (); $user = $setting [ 'aliyunsmskey' ]; //短信平臺帳號 $pass = md5($setting [ 'aliyunsmsaccessSecret' ]); //短信平臺密碼 $content = str_replace( '{code}' ,$code,$tmpcode); $content= '【' .$setting [ 'aliyunsmssign' ]. '】' .$content; //要發送的短信內容 $phone = $phonenum; //要發送短信的手機號碼 $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; // 狀態為0,說明短信發送成功 $message [ 'Message' ] = 'OK' ; } else { $message [ 'errorcode' ] = 1; $message [ 'Message' ] = '短信發送失敗' ; } return $message; } |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的WhatsnsV6.03問答系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類