点击这里给我发消息
26102014
phpcms短信接口_v9.5.5短信通接口系列说明V2014050101

phpcms短信接口_v9.5.5短信通接口系列说明V2014050101

短信接口 | phpcms短信接口_v9.5.5短信通接口系列说明V2014050101

本帖最后由 hehu158 于 2014-10-24 09:09

 

1、备份网站根目录下phpcms\modules\sms\classes\smsapi.class.php
如果此前没有修改过该文件,直接把phpcms文件夹复制到根目录下覆盖即可;如果之前修改过,需要替换其中send_sms函数的执行代码

 

//短信发送状态
                $status = $this->_sms_status();
                if(is_array($mobile)){
                        $mobile = implode(",", $mobile);
                }
                $content = safe_replace($content);
                if(strtolower($charset)=='utf-8') {
                        $send_content = iconv('utf-8','gbk',$content);//官网IS GBK
                }else{
                        $send_content = $content;
                }
                $send_time = strtotime($send_time);

 

                $target = "http://sms.106jiekou.com/utf8/sms.aspx";
                $sms_template="您的验证码是:【变量】。请不要把验证码泄露给其他人。如非本人操作,可不用理会!";
                $send_content=str_replace("【变量】",$send_content,$sms_template);
                //替换成自己的测试账号,参数顺序和wenservice对应
                $data = "account=".$this->userid."&password=".$this->sms_key."&mobile=".$mobile."&content=".rawurlencode($send_content);

 

                $url_info = parse_url($target);
                $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
                $httpheader .= "Host:" . $url_info['host'] . "\r\n";
                $httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n";
                $httpheader .= "Content-Length:" . strlen($data) . "\r\n";
                $httpheader .= "Connection:close\r\n\r\n";
                //$httpheader .= "Connection:Keep-Alive\r\n\r\n";
                $httpheader .= $data;

 

                $fd = fsockopen($url_info['host'], 80);
                fwrite($fd, $httpheader);
                $gets = "";
                while(!feof($fd)) {
                        $gets .= fread($fd, 128);
                }
                fclose($fd);

 

                //增加到本地数据库
                $sms_report_db = pc_base::load_model('sms_report_model');
                $send_userid = param::get_cookie('_userid') ? intval(param::get_cookie('_userid')) : 0;
                $ip = ip();

 

                $new_content = $content;
                if(strpos($gets, "100")) {
                         $sms_report_db->insert(array('mobile'=>$mobile,'posttime'=>SYS_TIME,'id_code'=>$new_content,'send_userid'=>$send_userid,'status'=>'100','msg'=>$send_content,'return_id'=>$gets,'ip'=>$ip));
                } else {
                $sms_report_db->insert(array('mobile'=>$mobile,'posttime'=>SYS_TIME,'send_userid'=>$send_userid,'status'=>'-2','msg'=>$new_content,'ip'=>$ip));
                }
                return $gets;

 

2打开http://www.dxton.com网站注册账号,后台配置接口设置
绑定ip选填)可以填写自己网站的ip地址,保证你在调用短信接口时的安全性,不懂的可以咨询在线客服;
图1-1 接口设置
3phpcms后台设置
模块(顶端)—短信平台(左侧)—平台设置,输入你在短信通平台中注册的账号跟密码(接口设置中的接口密码,注意不是账号的登陆密码)。
 
图1-2 phpcms后台短信通短信接口设置
 

二、个性化设置(***非必要***