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


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


接入说明:
    1.后台-系统-短信设置-配置 填写56短信网账号和密码
   class dxw_sms{
    protected $error = 0;
    protected $setting = array();
    protected $base_url = 'http://jiekou.56dxw.com/sms/webinterface.aspx';
    protected $notice_url = 'http://jiekou.56dxw.com/sms/webinterface.aspx';
    protected $captcha_url = 'http://jiekou.56dxw.com/sms/webinterface.aspx';
    protected $other_url = 'http://jiekou.56dxw.com/sms/webinterface.aspx';
    public function __construct($setting) {
        $this->setting = $setting;
    }
    /**
     * 发送模板短信
     * @param    string     $type 短信通道 手机号码集合,用英文逗号分开
     * @param    array      $option['mobile':手机号码集合,用英文逗号分开,'content':短信内容]
     * @return   boolean
     */
    public function sendTemplateSMS($type='captcha',$option){
        $data['account'] = $this->setting['appkey'];
        $data['password'] = $this->setting['secretKey'];
        //解析模板内容
        if($option['data']){
            foreach ($option['data'] as $key => $val) {
                $data['{'.$key.'}'] = $val;
            }
            $data['content'] = strtr($option['tpl'],$data);
        }else{
            $data['content'] = $option['tpl'];
        }
        $name = '_'.$type.'_url';
        $url = $this->$name;
        //遍历发送
        $mobile = explode(',',$option['mobile']);
        foreach ($mobile as $key => $val) {
            $data['mobile'] = $val;
            $post_data = http_build_query($data);
            $get = $this->_https_request($url,$post_data);
            $gets =  $this->xml_to_array($get);
            if($gets['SubmitResult']['code']!=2){
                $this->_error = $gets['SubmitResult']['msg'].' 短信发送失败,请联系服务商!';
                return false;
            }
        }
        return true;
    }
    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;
    }
    protected function _https_request($url,$data = null){
        if(function_exists('curl_init')){
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);
            curl_setopt($ch, CURLOPT_REFERER,_REFERER_);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
            curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
            if (!empty($data)){
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($curl);
            curl_close($curl);
            return $output;
        }else{
            $this->_error = '短信发送失败,请开启curl服务!';
            return false;
        }
    }
    public function getError(){
        return $this->_error;
    }
}
    

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