Tipask是一款100%開放源碼的PHP問答系統(tǒng),容易擴展,具有強大的負載能力和穩(wěn)定性。今天小編就以替換短信接口為例一步一步教大家如何開發(fā),進行替換的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信接口非常穩(wěn)定,發(fā)送速度快,注冊還送測試短信,推薦大家使用。
1:打開項目:resources\views\admin\setting\sms.blade.php 替換代碼12行到58行
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= "row" > <div class= "col-xs-12" > <h3>消息模板設(shè)置</h3> <div class= "alert alert-info" role= "alert" > 要使用短信通知以及驗證碼功能需要在阿里大于里面配置好消息模板,并且消息模板需要通過審核。<br /> 系統(tǒng)中的消息模板變量如下: <ol> <li>發(fā)送驗證碼:您的驗證碼是:${code},工作人員不會索取,請勿泄漏。</li> </ol> </div> <div class= "box box-default" > <form role= "form" name= "addForm" method= "POST" action= "{{ route('admin.setting.sms',['type'=>'template']) }}" > <input type= "hidden" name= "_token" id= "editor_token" value= "{{ csrf_token() }}" > <div class= "box-body" > <div class= "form-group" > <label for = "sms_code_template" >驗證碼消息模板</label> <input type= "text" name= "sms_code_template" class= "form-control" value= "{{ Setting()->get('sms_code_template') }}" placeholder= "您的驗證碼是:${code},工作人員不會索取,請勿泄漏" /> </div> </div> <div class= "box-footer" > <button type= "submit" class= "btn btn-primary" >保存</button> </div> </form> </div> </div> </div> |
2:打開項目:app\Services\SmsService.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
|
protected static function smsBaoSend($mobile, $smsTemplateId, $params){ $statusStr = array( "0" => "短信發(fā)送成功" , "-1" => "參數(shù)不全" , "-2" => "服務(wù)器空間不支持,請確認支持curl或者fsocket,聯(lián)系您的空間商解決或者更換空間!" , "30" => "密碼錯誤" , "40" => "賬號不存在" , "41" => "余額不足" , "42" => "帳戶已過期" , "43" => "IP地址限制" , "50" => "內(nèi)容含有敏感詞" ); $user = config( 'aliyunsms.access_key' ); //短信平臺帳號 $pass = md5(config( 'aliyunsms.access_secret' )); //短信平臺密碼 $content= '【' .config( 'aliyunsms.sign_name' ). '】' .str_replace( '${code}' ,$params[ 'code' ],$smsTemplateId); $phone = $mobile; //要發(fā)送短信的手機號碼 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl) ; if ($result != 0){ return $statusStr[$result]; } return $result; } |
經(jīng)過上面的替換,短信寶的短信平臺已經(jīng)替換成功了,可以正常使用了。
報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會人工審核,短信內(nèi)容3~5秒就可送達。
另外:我們已經(jīng)開發(fā)好完整的TipaskV3.5短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類