騎士人才系統是一套基于PHP+MYSQL為核心開發、免費 + 開源的專業人才系統。系統具執行效率高、模板自由切換、后臺管理功能靈活等諸多優秀特點。小編今天就以替換短信接口為例帶大家進行二次開發,我們使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用
1:打開項目:\Application\Home\Controller\ 新增SmsbaoController.class.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
|
<?php namespace Home\Controller; use Common\Controller\FrontendController; class SmsbaoController extends FrontendController{ public function _initialize() { parent::_initialize(); } /** * 安裝短信寶插件 */ public function index(){ $data[ 'name' ]= '短信寶(推薦)' ; $data[ 'alias' ]= 'smsbao' ; $map[ 'id' ]= '1' ; $res=D( 'sms' )->where($map)->save($data); //短信模板 $map_sms_tpl[ 'type' ]= 'qscms' ; $data_sms_tpl[ 'type' ]= 'smsbao' ; $sms_tpl_res=D( 'sms_templates' )->where($map_sms_tpl)->save($data_sms_tpl); if ($res&&$sms_tpl_res){ echo '短信寶插件安裝成功,請將Application/Home/Controller/SmsbaoController.class.php文件刪除' ; } else { echo '插件安裝失敗,請聯系短信寶客服' ; } } } |
2:打開項目:\Application\Common\qscmslib\sms\ 新增smsbao\smsbao.class.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
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
68
69
70
71
72
|
<?php class smsbao_sms{ protected $_error = 0; protected $setting = array(); public function __construct($setting) { $ this ->setting = $setting; } /** * 發送模板短信 * @param string $type 短信通道 手機號碼集合,用英文逗號分開 * @param array $option['mobile':手機號碼集合,用英文逗號分開,'content':短信內容] * @return boolean */ public function sendTemplateSMS($type= 'captcha' ,$option){ $data[ 'u' ] = $ this ->setting[ 'appkey' ]; $data[ 'p' ] = md5($ this ->setting[ 'secretKey' ]); //解析模板內容 if ($option[ 'data' ]){ foreach ($option[ 'data' ] as $key => $val) { $data[ '{' .$key. '}' ] = $val; } $data[ 'c' ] = '【' .$ this ->setting[ 'signature' ]. '】' .strtr($option[ 'tpl' ],$data); } else { $data[ 'c' ] = '【' .$ this ->setting[ 'signature' ]. '】' .$option[ 'tpl' ]; } //轉換編碼 //foreach ($data as $key => $val) { // $data[$key] = iconv('UTF-8','GB2312//IGNORE',$val); //} $name = '_' .$type. '_url' ; $url = $ this ->$name.http_build_query($data); //遍歷發送 //$mobile = explode(',',$option['mobile']); //foreach ($mobile as $key => $val) { if ($ this ->_https_request($url. '&m=' .$option[ 'mobile' ])== '0' ) { return true ; } else { return false ; } } protected function _https_request($url,$data = null ){ if (function_exists( 'curl_init' )){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_); curl_setopt($ch, CURLOPT_REFERER,_REFERER_); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); if (!empty($data)){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; } else { $ this ->_error = '短信發送失敗,請開啟curl服務!' ; return false ; } } public function getError(){ return $ this ->_error; } } ?> |
3:打開項目:\Application\Admin\View\default\Sms\config_edit.html 修改大概第10行
1
2
3
4
5
6
7
|
<div class= "toptip" > <div class= "toptit" >提示:</div> <p>短信模塊屬收費模塊,需申請開通后才能使用,請聯系我司客服申請開通。</p> <p class= "link_green_line" >資費標準請聯系短信寶客服獲取,更多介紹請進入 <a href= "http://www.gjrencai.com" target= "_blank" >短信寶官方網站</a></p> <p><font color= "red" >使用短信發送服務前,請確認短信服務商已正確配置!</font></p> <p><font color= "red" >阿里大于的短信暫時不能正常發送招聘類信息,使用前請先向阿里大于官方核實,謹慎使用!</font></p> </div> |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的騎士人才v6.0.20系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類