HadSky轻论坛是一款基于PHP+MySQL开源论坛程序,便于二次开发,小编对这款软件还是比较了解的,今天小编就以替换短信接口为例一步一步教大家如何开发,进行替换的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信接口非常稳定,发送速度快,注册还送测试短信,推荐大家使用。
首先我们打开项目\upload\app\hadskycloudserver\setting.hst文件,在177~136行左右添加配置短信宝信息的前端代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
div class="pk-row pk-padding-bottom-15"> < label class = "pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap" >短信宝用户名</ label > < div class = "pk-w-sm-8" > < input class = "pk-textbox" type = "text" name = "app_puyuetian_sms_smsbao_user" value = "{$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_USER']}" placeholder = "请填写短信宝用户名" > </ div > </ div > < div class = "pk-row pk-padding-bottom-15" > < label class = "pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap" >短信宝密码</ label > < div class = "pk-w-sm-8" > < input class = "pk-textbox" type = "text" name = "app_puyuetian_sms_smsbao_pass" value = "{$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_PASS']}" placeholder = "请填写短信宝密码" > </ div > </ div > < div class = "pk-row pk-padding-bottom-15" > < label class = "pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap" >短信宝签名</ label > < div class = "pk-w-sm-8" > < input class = "pk-textbox" type = "text" name = "app_puyuetian_sms_smsbao_sign" value = "{$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_SIGN']}" placeholder = "请填写短信宝签名" > </ div > </ div > |
接着打开项目\upload\app\hadskycloudserver\phpscript\sms_send.php文件,在53~69行左右替换短信宝发送短信功能的代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
if (! empty ( $_G [ 'SET' ][ 'APP_PUYUETIAN_SMS_SMSBAO_USER' ]) && ! empty ( $_G [ 'SET' ][ 'APP_PUYUETIAN_SMS_SMSBAO_PASS' ]) && ! empty ( $_G [ 'SET' ][ 'APP_PUYUETIAN_SMS_SMSBAO_SIGN' ])) { $content = '【' . $_G [ 'SET' ][ 'APP_PUYUETIAN_SMS_SMSBAO_SIGN' ]. '】 您的验证码为:' . $code . ',请妥善保存。' ; $url = 'http://api.smsbao.com/sms?u=' . $_G [ 'SET' ][ 'APP_PUYUETIAN_SMS_SMSBAO_USER' ]. '&p=' .md5( $_G [ 'SET' ][ 'APP_PUYUETIAN_SMS_SMSBAO_PASS' ]). '&m=' . $phonenumber . '&c=' . $content ; $ret = file_get_contents ( $url ); if ( $ret == 0) { $r [ 'state' ] = 'ok' ; } else { $r [ 'state' ] = $ret ; } } else { $_apiurl = "http://www.hadsky.com/index.php?c=app&a=zhanzhang:index3&s=sendsms&domain={$_G['SYSTEM']['DOMAIN']}&code={$code}&phonenumber={$phonenumber}&sitekey=" . md5( $_G [ 'SET' ][ 'APP_HADSKYCLOUDSERVER_SITEKEY' ] . $_G [ 'SYSTEM' ][ 'DOMAIN' ]); $r = json_decode(GetPostData( $_apiurl , '' , 10), TRUE); } |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。我们进行测试发送。
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的HadSky轻论坛短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类