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= "https://www.smsbao.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类
微信类