阿里云短信服务

     /**
     * Info: 短信通知(第一步)
     */
	function SMS_notification($post){

		// 您的服务密码为${code},请妥善保管。订单尾号${orderid},预计${time}上门服务。小蚁到家${name},电话${phone}。小蚁到家竭诚为您服务!
		// $orderid = input('orderid');
		// $time = input('time');
		// $name =  input('name');
		// $phone =  input('phone');

        $rand = rand(000001,999999);

        // $mobile = trim(input('post.mobile'));
		$mobile = trim($post['mobile']);
        $con['rand'] = $rand;//短信验证码
        // $con['tel'] = $mobile;
		$con['tel'] = $post['mobile'];
		
		//新增模板参数
		$con['order_no'] = $post['order_no'];
		$con['time'] = $post['time'];
		$con['name'] = $post['name'];
		$con['phone'] = $post['phone'];

        $preg_phone='/^1[34578]\d{9}$/ims';

        $rtn = [];

        if(!$mobile)
        {

            $rtn['code'] = 1;
            $rtn['message'] = '手机号为空';

        }else{

            if(preg_match($preg_phone,$mobile)){

                require_once('../extend/alidy/demo/SendSms.php');

                $alisms = Db::name('alisms')
                    ->field('accesskeyid,accesskeysecret,signname,mobilelogin')
                    ->find(1);
					
                $sendSms = new \Aliyun\DySDKLite\Sms\SendSms();
				
                $res = get_object_vars($sendSms -> sendSms_yzm($con,$alisms));
				// dump($res);
                if($res['Message'] == 'OK')
                {
                    $rtn['code'] = 0;
					$rtn['rand'] = $rand;
                }

            }else{
                $rtn['code'] = 1;
                $rtn['message'] = '手机号格式不正确';
            }
        }


		
        return $rtn;
		// page_result(0, "ok", array(
		// 	'rtn'	=> $rtn
		// ));
	}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值