zzzphp是一款开源的跨平台网站内容管理系统,他是基于PHP+MYSQL开发的 ,是一套非常适合用做系统建站或者进行二次开发的程序核心,小编对他还是比较了解的,今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,我们今天讲解的是2.1.4版本,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:\admin\template\systemedit.tpl (admin不是安装默认目录,可根据实际情况寻找)添加短信宝设置页面
| 1 2 3 4 5 6 | <div class="col-sm-4">    <select  class="form-control"name="smsserver">       <option value="1"{$check_onoff [c smsserver],"selected",'',1}>短信宝</option>       <option value="2"{$check_onoff [c smsserver],"selected",'',2}>阿里云</option>    </select></div> | 
2:打开项目:\inc\zzz_main.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 23 24 25 26 27 28 29 30 31 | functionsend_sms( $mobile, $content ) {    if( conf( 'smsmark') == 0 )exit;    $t0 = time();    $t1 = get_session( 'smstime');    $t2 = 59 - ( $t0 - $t1 );    $ip = ip();    if( $t2 > 0 )die( '0请等待'. $t2 . '秒再尝试');    if( empty( $_SESSION[ 'code'] ) )die( '0警报:正在尝试刷短信,已通知管理员并将你加入黑名单。');    $prevtime = strtotime( db_select( 'sms', 'smsaddtime', array( 'smsip'=> $ip ), array( 'id'=> 'desc') ) );    $t3 = $t0 - $prevtime;    if( $t3 < 60 )die( '0请不要尝试连续请求!');    $smsid = conf( 'smsid');    $smspw = md5(conf( 'smspw'));    $content = '【'.conf( 'smssign').'】'.$content;//  $post_string = "uid=" . $smsid . "&auth=" . $smspw . "&mobile=" . $mobile . "&msg=" . $content . "&expid=0&encode=utf-8";    $sendurl = $url."sms?u=".$smsid."&p=".$smspw."&m=".$mobile."&c=".urlencode($content);    $data = file_get_contents($sendurl);//  $sms_data = splits( $data, ',' );    //curl_close($ch);    switch($data) {        case"0":            $tempstr = "1发送成功";            break;        default:            $tempstr = "0发送失败";    }    set_session( 'smstime', $t0 );    db_exec( "insert into [dbpre]sms(smsmobile,smscontent,smsip,smsaddtime,smsbackinfo,smsonoff,smsid,smspw)values('". $mobile . "','". $content . "','". $ip . "','". date( 'Y-m-d H:i:s' ) . "','" . $tempstr . "'," . cleft( $tempstr, 0, 1 ) . ",'". $smsid . "','". hidestr( $smspw, 8 ) . "')");    return$tempstr;} | 
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的zzzphpV2.14系统短信宝插件,点击此链接 下载及查看安装流
最新更新
电商类
CMS类
微信类