騎士人才系統(tǒng)是一套基于PHP+MYSQL為核心開(kāi)發(fā)、免費(fèi) + 開(kāi)源的專業(yè)人才系統(tǒng)。系統(tǒng)具執(zhí)行效率高、模板自由切換、后臺(tái)管理功能靈活等諸多優(yōu)秀特點(diǎn)。小編今天就以替換短信接口為例帶大家進(jìn)行二次開(kāi)發(fā),我們使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的短信接口,我們短信寶短信群發(fā)平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用
1:打開(kāi)項(xiàng)目:\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
|
<?phpnamespace 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 '短信寶插件安裝成功,請(qǐng)將Application/Home/Controller/SmsbaoController.class.php文件刪除'; }else{ echo '插件安裝失敗,請(qǐng)聯(lián)系短信寶客服'; } }} |
2:打開(kāi)項(xiàng)目:\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
|
<?phpclass smsbao_sms{ protected $_error = 0; protected $setting = array(); public function __construct($setting) { $this->setting = $setting; } /** * 發(fā)送模板短信 * @param string $type 短信通道 手機(jī)號(hào)碼集合,用英文逗號(hào)分開(kāi) * @param array $option['mobile':手機(jī)號(hào)碼集合,用英文逗號(hào)分開(kāi),'content':短信內(nèi)容] * @return boolean */ public function sendTemplateSMS($type='captcha',$option){ $data['u'] = $this->setting['appkey']; $data['p'] = md5($this->setting['secretKey']); //解析模板內(nèi)容 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']; } //轉(zhuǎn)換編碼 //foreach ($data as $key => $val) { // $data[$key] = iconv('UTF-8','GB2312//IGNORE',$val); //} $name = '_'.$type.'_url'; $url = $this->$name.http_build_query($data); //遍歷發(fā)送 //$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 = '短信發(fā)送失敗,請(qǐng)開(kāi)啟curl服務(wù)!'; return false; } } public function getError(){ return $this->_error; }}?> |
3:打開(kāi)項(xiàng)目:\Application\Admin\View\default\Sms\config_edit.html 修改大概第10行
|
1
2
3
4
5
6
7
|
<div class="toptip"> <div class="toptit">提示:</div> <p>短信模塊屬收費(fèi)模塊,需申請(qǐng)開(kāi)通后才能使用,請(qǐng)聯(lián)系我司客服申請(qǐng)開(kāi)通。</p> <p class="link_green_line">資費(fèi)標(biāo)準(zhǔn)請(qǐng)聯(lián)系短信寶客服獲取,更多介紹請(qǐng)進(jìn)入 <a href="http://www.fyzp06.cn" target="_blank">短信寶官方網(wǎng)站</a></p> <p><font color="red">使用短信發(fā)送服務(wù)前,請(qǐng)確認(rèn)短信服務(wù)商已正確配置!</font></p> <p><font color="red">阿里大于的短信暫時(shí)不能正常發(fā)送招聘類信息,使用前請(qǐng)先向阿里大于官方核實(shí),謹(jǐn)慎使用!</font></p></div> |
經(jīng)過(guò)上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。進(jìn)行測(cè)試發(fā)送:

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開(kāi)發(fā)好完整的騎士人才v6.0.20系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類