优优 问答系统 是一套基于PHP+MYSQL为核心开发、免费 + 开源的专业问答系统。基于THINKPHP框架开发,使用和安装及其简单,系统具执行效率高、模板自由切换、后台管理功能灵活等诸多优秀特点。我们将不断的完善、创新,优优问答系统会为您带来全新的体验!今天小编就以替换短信接口为例告诉大家如何进行二次开发,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
首先打开项目:\tpl\Admin\default\Sms\config.html文件,替换25~46行左右代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
< div class = "fl" >服务商:</ div > < div class = "fr" > < div class = "imgradio" > < input name = "UU_SMS_SERVICE" type = "hidden" value = "{$show.UU_SMS_SERVICE}" /> < div class = "radio {$show['UU_SMS_SERVICE']==='smsbao' ? 'select' : ''}" data = "smsbao" >短信宝</ div > < div class = "radio {$show['UU_SMS_SERVICE']==='aliyun' ? 'select' : ''}" data = "aliyun" >阿里云</ div > < div class = "radio {$show['UU_SMS_SERVICE']==='alidayu' ? 'select' : ''}" data = "alidayu" >阿里大于</ div > < div class = "clear" ></ div > </ div > </ div > < div class = "fl" >APPKEY/短信宝用户名:</ div > < div class = "fr" >< input name = "UU_SMS_APPKEY" type = "text" class = "input_text_default" maxlength = "60" placeholder = "输入APPKEY" value = "{$show.UU_SMS_APPKEY}" /> </ div > < div class = "fl" >SECRETKEY/短信宝密码:</ div > < div class = "fr" > < input name = "UU_SMS_SECRETKEY" type = "text" class = "input_text_default" maxlength = "100" placeholder = "输入SECRETKEY" value = "{$show.UU_SMS_SECRETKEY}" /> </ div > < div class = "fl" >SIGNATURE/短信签名:</ div > < div class = "fr" > < input name = "UU_SMS_SIGNATURE" type = "text" class = "input_text_default" maxlength = "300" placeholder = "输入SIGNATURE(签名),如:优优问答" value = "{$show.UU_SMS_SIGNATURE}" /> </ div > </ div > |
最后打开:\apps\Common\Common\function.php文件,替换send_sms方法,增加myfunction方法
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
|
function send_sms( $mobile , $params , $alias ) { $sms_open = C( 'UU_SMS_OPEN' ); if ( $sms_open <> '1' ) { $return [ 'status' ] = 0; $return [ 'content' ] = '发送失败,短信功能未开启!' ; return $return ; } $config = array ( 'appkey' => C( 'UU_SMS_APPKEY' ), 'secretKey' => C( 'UU_SMS_SECRETKEY' ), 'signature' => C( 'UU_SMS_SIGNATURE' ) ); if (C( 'UU_SMS_SERVICE' ) == 'smsbao' ) { $templateCode = getTemplateCode( $alias ); $key = array_map ( "myfunction" , array_keys ( $params )); $value = array_values ( $params ); $content = str_replace ( $key , $value , $templateCode [ 'tpl' ]); $url = 'http://api.smsbao.com/sms?u=' .C( 'UU_SMS_APPKEY' ). '&p=' .md5(C( 'UU_SMS_SECRETKEY' )). '&m=' . $mobile . '&c=【' .C( 'UU_SMS_SIGNATURE' ). '】' . $content ; $ret = file_get_contents ( $url ); if ( $ret != 0) { $return [ 'status' ] = 0; $return [ 'content' ] = $ret ; return $return ; } else { $result [ 'status' ] = 1; $result [ 'content' ] = '发送成功' ; } } return $result ; } function myfunction( $v ) { return ( '${' . $v . '}' ); } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的uuask问答系统的短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类