56短信网
56短信接口-易接入,最全的短信接口
UQCMS短信插件修改
来源:56短信网 发布人:技术部 发表于:2019-07-23 09:24:59 阅读:
导读: UQCMS短信插件修改,56短信插件目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。

UQCMS短信插件修改,56短信插件目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。


接入说明:
1.后台-设置-接口-短信通知- 填写相应的56短信网的账号和密码
2.后台-设置-接口-短信通知,编辑模版,保存点击完成
3.核心文件:\UQframework\class\api    新增加sms_dxw.class.php 文件,代码如下

 
 class sms_dxw {
        private $dateTimeFormat = 'Y-m-d\TH:i:s\Z';
        function __construct($app_id, $app_key){
            $this->app_id = $app_id;
            $this->app_key = $app_key;
             $this->url = 'http://jiekou.56dxw.com/sms/webinterface.aspx';
         }

        function send($mobile, $param_arr, $tpl_content, $sign){
            foreach ($param_arr as $key=>$vo) {
                $tpl_content = str_replace('${' . $key . '}', $param_arr[$key], $tpl_content);
            }            

            $post_data = "account=".$this->app_id."&password=".$this->app_key."&mobile=".$mobile."&content=".rawurlencode($tpl_content);
            $gets =  $this->xml_to_array($this->Post($post_data, $this->url));
             if($gets['SubmitResult']['code']==1){
                 $result_info['error'] = '0';
                 $result_info['msg'] = '发送成功';
                 return $result_info;
            }else{
                $result_info['error'] = '1';
                $result_info['msg'] = $gets['SubmitResult']['msg'];
                return $result_info;
            }

        }
        //请求数据到短信接口,检查环境是否 开启 curl init。
        function Post($curlPost,$url){
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_HEADER, false);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_NOBODY, true);
                curl_setopt($curl, CURLOPT_POST, true);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
                $return_str = curl_exec($curl);
                curl_close($curl);
                return $return_str;
        }


        //将 xml数据转换为数组格式。
        function xml_to_array($xml){
            $reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
            if(preg_match_all($reg, $xml, $matches)){
                $count = count($matches[0]);
                for($i = 0; $i < $count; $i++){
                $subxml= $matches[2][$i];
                $key = $matches[1][$i];
                    if(preg_match( $reg, $subxml )){
                        $arr[$key] = $this->xml_to_array( $subxml );
                    }else{
                        $arr[$key] = $subxml;
                    }
                }
            }
            return $arr;
        }

    }

为您打造简单,易接入的短信接口服务 短信接口文档 扫扫加技术微信
关于56短信网
  • 联系我们:
  • 电话:0311-85235895
  • 0311-89801332
  • Emaill:
  • jiekou@56dxw.com
  • (#替换成@)
栏目导航
短信接口文档
56短信插件
扫一扫 加微信
享24小时服务
版权所有:56短信网 网络经营许可证编号:冀ICP备08006792号