使用阿里大鱼短信发送验证码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

<无详细内容>
    public function index()
    {
        $client  = new Client;
        $request = new SmsNumSend;

        // 短信内容参数
        $smsParams = [
            'code'    => $this->randString(),
            'product' => '测试的'
        ];

        // 设置请求参数,具体参数可以参考官方文档
        $req = $request->setSmsTemplateCode('SMS_6620027')
            ->setRecNum('18600000000')
            ->setSmsParam(json_encode($smsParams))
            ->setSmsFreeSignName('注册验证')
            ->setSmsType('normal')
            ->setExtend('123456');

        print_r($client->execute($req));
    }

    /**
     * 获取随机位数数字
     * @param  integer $len 长度
     * @return string       
     */
    protected static function randString($len = 6)
    {
        $chars = str_repeat('0123456789', $len);
        $chars = str_shuffle($chars);
        $str   = substr($chars, 0, $len);
        return $str;
    }