AiJiaCMS是基于PHP+MYSQL开发的y一款房产门户网站,采用超量静态页面布置,模版与分离扩展性架构,开放型代码,便于进行二次开发,小编对于这款软件还是比较了解的,今天小编就以替换短信接口为例,一步一步教大家如何进行二次开发,短信接口使用的是我们短信宝短信群发平台,我们短信宝非常稳定,发送速度快,注册就送测试条数,推荐大家使用。
首先我们修改后台模版文件,打开项目\admin\template\setting.tpl.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
|
< div id = "Tabs7" style = "display:none" > < div class = "tt" >手机短信</ div > < table cellpadding = "2" cellspacing = "1" class = "tb" > < tr > < td class = "tl" >手机短信</ td > < td > < input type = "radio" name = "setting[sms]" value = "1" <?php if($sms){ ?>checked <? php } ?> onclick="Ds('dsms');"/> 开启 < input type = "radio" name = "setting[sms]" value = "0" <?php if(!$sms){ ?>checked <? php } ?> onclick="Dh('dsms');"/> 关闭 < img src="<?php echo AJ_SKIN;?>image/mobile.gif" align="absmiddle"/> < a href = "http://www.smsbao.com/reg/" target = "_blank" class = "t" >[免费申请帐号]</ a > </ td > </ tr > < tbody id = "dsms" style="display:<?php if(!$sms) echo 'none';?>"> <? php if($sms && $sms_uid && $sms_key) { ?> < tr > < td class = "tl" >短信余额</ td > < td > </ tr > <? php } ?> < tr > < td class = "tl" >短信宝用户名</ td > < td >< input name = "setting[sms_uid]" type = "text" value="<?php echo $sms_uid;?>" size="30"/></ td > </ tr > < tr > < td class = "tl" >短信宝账号密码</ td > < td >< input name = "setting[sms_key]" type = "password" id = "sms_key" size = "30" value="<?php echo $sms_key;?>" onfocus="if(this.value.indexOf('**')!=-1)this.value='';"/></ td > </ tr > < tr > < td class = "tl" >短信单价</ td > < td >< input name = "setting[sms_fee]" type = "text" value="<?php echo $sms_fee;?>" size="5"/> <? php echo $AJ['money_unit'];?>/条 <? php tips('此项针对会员收费');?></ td > </ tr > < tr > < td class = "tl" >每日上限</ td > < td >< input name = "setting[sms_max]" type = "text" value="<?php echo $sms_max;?>" size="5"/> 条 <? php tips('特指会员注册、找回密码、手机验证等需要发送验证码场景,同一手机号码或会员每日最大发送数量,填0为不限制,建议填5左右的数字,以免恶意发送');?></ td > </ tr > < tr > < td class = "tl" >短信长度</ td > < td >< input name = "setting[sms_len]" type = "text" value="<?php echo $sms_len;?>" size="5"/> 字/条</ td > </ tr > < tr > < td class = "tl" >成功标识</ td > < td >< input name = "setting[sms_ok]" type = "text" value="<?php echo $sms_ok;?>" size="10"/> <? php tips('短信发送成功标识字符,系统根据此字符确定是否扣除会员短信余额');?></ td > </ tr > < tr > < td class = "tl" >短信内容签名</ td > < td >< input name = "setting[sms_sign]" type = "text" value="<?php echo $sms_sign;?>" size="30"/> <? php tips('将显示在短信内容结尾,以便会员识别,请尽量简短,正确的格式为【签名】,例如 【某某网】。包含签名的短信会被运营商认为是更正规的短信,从而进入更快的发送通道');?></ td > </ tr > </ tbody > </ table > </ div > |
然后修改短信发送接口文件,在项目\include\global.func.php,修改send_sms方法,修改代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
function send_sms( $mobile , $message , $encode , $word = 0, $time = 0){ global $db , $AJ , $AJ_TIME , $AJ_IP , $_username ; if (! $AJ [ 'sms' ] ||! $AJ [ 'sms_uid' ] ||! $AJ [ 'sms_key' ]) return false; $message = substr ( $message ,0, strlen ( $message )- strlen ( $AJ [ 'sms_sign' ])); $url = "http://api.smsbao.com/sms?u=" . $AJ [ 'sms_uid' ]. "&p=" .md5( $AJ [ 'sms_key' ]). "&m=" . $mobile . "&c=【" . $AJ [ 'sms_sign' ]. "】" . $message ; $ch = curl_init(); curl_setopt( $ch ,CURLOPT_POST,1); curl_setopt( $ch ,CURLOPT_POSTFIELDS, $rdata ); curl_setopt( $ch ,CURLOPT_URL, $url ); curl_setopt( $ch ,CURLOPT_RETURNTRANSFER,TRUE); $result = curl_exec( $ch ); curl_close( $ch ); $code = '' ; if (! $result == '0' ){ $code = 'Can Not Connect SMS Server' ; } else { $code = $AJ [ 'sms_ok' ]; } $db ->query( "INSERT INTO {$db->pre}sms (mobile,message,word,editor,sendtime,code,encode) VALUES ('$mobile','$message','$word','$_username','$AJ_TIME','$code','$encode')" ); return $code ; } |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行发送测试:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
最新更新
电商类
CMS类
微信类