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

2016-05-12 0 154
使用阿里大鱼短信发送验证码

<无详细内容>

    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;
    }

遇见资源网 php 使用阿里大鱼短信发送验证码 http://www.ox520.com/8184.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务