CMSeasy短信接口替换

来源:互联网 发布:ipad有淘宝卖家版吗 编辑:程序博客网 时间:2024/06/05 00:23

cmseasy是一款基于 PHP+Mysql 架构的网站内容管理系统,也是一个 PHP 开发平台。 采用模块化方式开发,功能易用便于扩展,可面向大中型站点提供重量级网站建设解决方案。使用范围非常广泛。本人对该系统还是比较熟悉的,今天我就来分享一下,如何进行二次开发。我以替换短信接口为例,一步一步的手把手教大家开发过程,我们做演示的短信平台是短信宝(http://www.smsbao.com)短信平台,我们公司和短信宝平台合作好几年了,他们的平台非常稳定,而且快速,注册还送免费测试短信,大家可以在短信宝平台注册一个账号,进行测试。

第一步:打开项目/lib/plugins/userfunction.php,替换发送短信的业务代码,替换的代码从652行~671行,代码如下图所示:

function sendMsg($mobile, $content) {    $tc = file_get_contents('config/sms.tmp.php');    $tmp = explode('@', $tc);    if ($tmp[0] >= config::get('sms_maxnum') && $tmp[1] == date('Y-m-d')) {        front::flash('发送失败,请检查用户名、密码或剩余条数');        return -200;    }    $param['u']=config::get('sms_username');    $param['p']=md5(config::get('sms_password'));    $param['m']=$mobile;    $param['c']="【".config::get('sms_sign')."】".$content;    $url="http://api.smsbao.com/sms?".http_build_query($param);    $res=file_get_contents($url);    if ($rs == '0') {        $num = $tmp[0] + 1;        file_put_contents('config/sms.tmp.php', $num . '@' . date('Y-m-d'));    }    return $res;}

修改配置文件,项目/config/config.php文件,1233~1300行左右,替换代码为:

//sms-短信设置{'sms_username'=>'', //用户名[<span class="hotspot" onmouseover="tooltip.show('请输入短信平台注册时填写的用户名!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>&nbsp&nbsp;<a href=http://smsbao.com target=_blank  class=btn_a>注册用户</a>]//sms-短信设置{'sms_password'=>'',  //密码[<span class="hotspot" onmouseover="tooltip.show('请输入短信平台注册时填写的密码!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]'sms_sign'=>'', //短信签名[<span class="hotspot" onmouseover="tooltip.show('请输入短信签名!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>&nbsp&nbsp;]'sms_on'=>'0', //短信开关[<span class="hotspot" onmouseover="tooltip.show('设置是否开启短信通知功能!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/开启/0/关闭'sms_keyword'=>'共产党,江泽民', //替换非法字符[<span class="hotspot" onmouseover="tooltip.show('设置屏蔽短信中的非法字符,多个字符用英文逗号分隔!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]'sms_maxnum'=>'100',  //最多发送[<span class="hotspot" onmouseover="tooltip.show('每天发送的最大条数!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]'sms_reg_on'=>'1',//注册发送[<span class="hotspot" onmouseover="tooltip.show('设置用户注册后,是否发送欢迎短信!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/是/0/否'sms_guestbook_on'=>'1', //留言发送[<span class="hotspot" onmouseover="tooltip.show('设置客户确认留言后,是否向客户发送确认收到留言通知!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/是/0/否'sms_order_on'=>'1', //订单发送=>1/是/0/否'sms_form_on'=>'1', //表单发送[<span class="hotspot" onmouseover="tooltip.show('设置客户确认留言后,是否向客户发送确认表单内容!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/是/0/否'sms_guestbook_admin_on'=>'1',//确认留言[<span class="hotspot" onmouseover="tooltip.show('客户确认留言后,是否向管理员发送通知!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/是/0/否'sms_form_admin_on'=>'1',//确认表单[<span class="hotspot" onmouseover="tooltip.show('客户确认表单后,是否向管理员发送通知!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/是/0/否'sms_order_admin_on'=>'1', //确认订单[<span class="hotspot" onmouseover="tooltip.show('客户确认订单后,是否向管理员发送通知!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/是/0/否'sms_consult_admin_on'=>'1',  //开启咨询[<span class="hotspot" onmouseover="tooltip.show('是否开启页底右侧悬浮短信咨询!');" onmouseout="tooltip.hide();"><img src="./images/admin/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;" /></span>]=>1/是/0/否//}

emseasy5.6 utf8版本系统后台设置登录短信验证不能发送验证码的bug,在此次演示也修复了,修改项目/template/admin/admin/login.php文件,替换代码63~74行左右,替换代码如下:

<input placeholder="{lang(tel)}" type='text' id="tel"  name="tel" value="" tabindex="3" class="input" /><div class="blank20"></div><input id="btm_sendMobileCode" onclick="sendMobileCode('{url('tool/smscode')}',$('#tel'));" type="button" value="{lang(send_cell_phone_verification_code)}" /><input type='text' placeholder="{lang(please_enter_the_phone_verification_code)}" id="mobilenum" name="mobilenum" /><div class="blank20"></div>{/if}{if config::get('verifycode') == 1}<li><input type='text' id="verify"  tabindex="3"  name="verify" />{verify()}</li>{/if}{if config::get('verifycode') == 2}<li><div id="verifycode_embed"></div>

好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。

原创粉丝点击