骑士人才系统替换V4.2.3版本短信接口替换
发表日期:2017-09-08 文章编辑:短信宝小编 浏览次数:
骑士人才系统是基于PHP+MYSQL为核心开发的招聘类型web系统,它是免费的和开源的,使用范围非常广泛。前段时间小编为大家介绍了V3.7版本的短信接口替换,今天小编就为大家带来V4.2.3版本的短信接口替换,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台发送速度快,而且非常稳定,注册就送测试帐号。
首先,我们先更换后台的显示界面文件。打开模板文件,替换一下模板文件。打开项目\Application\Admin\View\default\Sms\config_edit.html文件,替换的代码从2行~9行,代码如下图所示:
|
1
2
3
4
5
6
7
8
|
<div class="toptip link_g"> <h2>提示:</h2> <p> <br /> <p><font color="red">开启短信发送服务前,请确认短信服务商已正确配置!</font></p> </div> |
经过替换后,所有的显示都变成短信宝短信平台的了。第一步完成。接下来替换发送短信的业务代码。打开项目\Application\Common\qscmslib\sms文件,建立一个smsbao的文件夹,在smsbao文件夹下创建两个文件index.html和smsbao.class.php文件。index.html文件内容为空,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
73
74
75
76
77
78
79
80
81
82
83
|
<?php// +----------------------------------------------------------------------// | 74CMS [ WE CAN DO IT JUST THINK IT ]// +----------------------------------------------------------------------// | Copyright (c) 2009 http://www.74cms.com All rights reserved.// +----------------------------------------------------------------------// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )// +----------------------------------------------------------------------// | Author: // +----------------------------------------------------------------------// | ModelName: 短信宝短信类// +----------------------------------------------------------------------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; }}?> |
最后我们在项目\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
|
<?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 '短信宝插件安装成功,请将Application/Home/Controller/SmsbaoController.class.php文件删除'; }else{ echo '插件安装失败,请联系短信宝客服'; } } }?> |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。最后我们进行发送测试。

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
- 上一篇:somCNS短信接口替换 下一篇:方维团购V3.07版本短信插件开发

