服务热线:400-699-1455
SMS短信平台
SMS短信通
网站API短信接口
24小时短信自助平台 短信平台自助注册+自助发送+自助充值
网站短信插件类别
电商
CMS
联系我们

服务热线:

400-699-1455 9:00-21:00 ×365天

QQ: 410001455

网建在线客服

手机微信扫一扫

网建短信通 网站建站短信插件 阿狸子V2.9.0网建短信接口插件

阿狸子V2.9.0网建短信接口插件


网建SMS短信通API接口接入流程

阿狸子订单系统,带 PC 前台模块+WAP 手机版模块(和 PC 端自适应)+文章模块+用户分销模块。
整合多个支付接口(码支付,支付宝,微信,h5),支持二维码推广。

文件 \Home\Lib\Action\ApiAction.class.php 大概在370行位置开始。
可以把原 private function sendSMS($order_id)类函数替换成下面的代码,替换前请先备份文件。

    private function sendSMS($order_id){
        if(empty($this->aliziConfig['sms_send'])){
            return array('status'=>0);
        }

        $order = M('Order')->where(array('id'=>$order_id))->find();
        if(empty($order)) return array('status'=>0);

        
        $item = M('Item')->where('id='.$order['item_id'])->field('id,sms_send')->find();
        $sms = json_decode($item['sms_send'],true);
        $status=$order['status'];
        if($sms[$status]['status']==1 && !empty($sms[$status]['content'])){
            //发送内容替换
            $express = C('DELIVERY');

            $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
            $aliziHost = $http_type.$_SERVER['HTTP_HOST'].C('ALIZI_ROOT');
            $confirmUrl = $aliziHost.(C('URL_MODEL')==2?'a/'.$order['order_no']:'Api/confirm.php?id='.$order['order_no']);
			
			$mobiles = $order['mobile'];
			if(!empty($this->aliziConfig['sms_admin_mobile'])){
				switch ($this->aliziConfig['sms_admin']) {
					case '1': $mobiles = $this->aliziConfig['sms_admin_mobile'];break;
					case '2': $mobiles .= ','.$this->aliziConfig['sms_admin_mobile'];break;
				}
			}
			
            $replace = array(
                '{[AliziTitle]}'     => $order['item_name'],
                '{[AliziParams]}'     => $order['item_params'],
                '{[AliziName]}'     => $order['name'],
                '{[AliziQuantity]}'     => $order['quantity'],
                '{[AliziPrice]}'     => $order['total_price'],
                '{[AliziExpress]}'     => $express[$order['delivery_name']],
                '{[AliziExpressNum]}'     => $order['delivery_no'],
                '{[AliziConfirmUrl]}'     => $confirmUrl,

                '#title#'     => $order['item_name'],
                '#params#'     => $order['item_params'],
                '#name#'     => $order['name'],
                '#mobile#'     => $order['mobile'],
                '#quantity#'     => $order['quantity'],
                '#price#'     => $order['total_price'],
                '#express#'     => $express[$order['delivery_name']],
                '#expressNum#'     => $order['delivery_no'],
                '#confirmUrl#'     => $confirmUrl,
                '#orderNum#'     => $order['order_no'],
            );
            $content = str_replace(array_keys($replace),array_values($replace),$sms[$status]['content']);

// ======  网建短信通API接口新增内容 开始 ====== 
            $url               = "https://utf8api.smschinese.cn/?";
            $param['Uid']      = $this->aliziConfig['sms_account'];
            $param['Key']      = $this->aliziConfig['sms_password'];
            $param['smsMob']   = $order['mobile'];
            $param['smsText']  = $content;
            $result            = file_get_contents($url . http_build_query($param));
            //短信发送成功与否状态都保存到数据库中
            if( is_numeric( $result ) ){
                $sendData = array(
                    'order_id'=>$order_id,
                    'order_status'=>$order['status'],
                    'mobile'=>$mobiles,
                    'sent_content'=>$content,
                    'sent_time'=>date('Y-m-d H:i:s'),
                    'sent_status'=>$result,
                );
                M('Sent')->add($sendData);
             }
// ======  网建短信通API接口新增内容 结束 ======   
        
            /*原文件,替换成上面网建短信通接口代码
            $data = array(
                'method'=>'send',
                'account'=>$this->aliziConfig['sms_account'],
                'password'=>$this->aliziConfig['sms_password'],
                'mobile'=>$mobiles,
                'content'=>$content,
            );
            $rs = http(C('ALIZI_API').'/sms/','POST',$data);
			
            $ret = json_decode($rs,true);
            if($ret['status']==1 || $ret['msg']=='ok'){
                $sendData = array(
                    'order_id'=>$order_id,
                    'order_status'=>$order['status'],
                    'mobile'=>$mobiles,
                    'sent_content'=>$content,
                    'sent_time'=>date('Y-m-d H:i:s'),
                    'sent_status'=>1,
                );
                M('Sent')->add($sendData);
            }
            */
        }
    }


按照下图填写用户名和短信接口秘钥



如有疑问请联系客服咨询

沪ICP备2021011364号-1 Copyright © 2006-2022 webchinese.cn Inc. All Rights Reserved 网建 版权所有