阿里云短信發送類

瀏覽:915 最后更新:2019-10-21 13:09 分類:類庫 關鍵字: 阿里云 短信
bingher/ali-smshttps://github.com/hbh112233abc/ali-sms
安裝composer require bingher/ali-sms配置文件config/ali_sms.php<?php
return [
    'version' => '2017-05-25',
    'host' => 'dysmsapi.aliyuncs.com',
    'scheme' => 'http',
    'region_id' => 'cn-hangzhou',
    'access_key' => '',
    'access_secret' => '',
    'product' => '海邁電子檔案平臺',
    'actions' => [
        'register' => [
            'sign_name' => '注冊驗證',
            'template_code' => 'SMS_67105498',
            'template_param' => [
                'code' => '',
                'product' => '',
            ]
        ],
        'login' => [
            'sign_name' => '登錄驗證',
            'template_code' => 'SMS_67105500',
            'template_param' => [
                'code' => '',
                'product' => '',
            ]
        ],
        'change_password' => [
            'sign_name' => '變更驗證',
            'template_code' => 'SMS_67105496',
            'template_param' => [
                'code' => '',
                'product' => '',
            ]
        ],
    ],
];

調用示例:<?php
use bingher\sms\facade\ThinkAliSms;

ThinkAliSms::login('18759201xxx',['code'=>123456]);
傳參為:手機號,template_param數組

特色功能,通過配置actions內容即可調用
如以上配置包含三個調用方式:ThinkAliSms::login('18759201xxx',['code'=>123456]);
ThinkAliSms::register('18759201xxx',['code'=>123456]);
ThinkAliSms::change_password('18759201xxx',['code'=>123456]);
//或
ThinkAliSms::changePassword('18759201xxx',['code'=>123456]);
如果我們在actions中增加配置  ...
  'actions' => [
        'register' => [
            'sign_name' => '注冊驗證',
            'template_code' => 'SMS_67105498',
            'template_param' => [
                'code' => '',
                'product' => '',
            ]
        ],
        'login' => [
            'sign_name' => '登錄驗證',
            'template_code' => 'SMS_67105500',
            'template_param' => [
                'code' => '',
                'product' => '',
            ]
        ],
        'change_password' => [
            'sign_name' => '變更驗證',
            'template_code' => 'SMS_67105496',
            'template_param' => [
                'code' => '',
                'product' => '',
            ]
        ],
        'coupon' => [
            'sign_name' => '優惠券',
            'template_code' => 'SMS_6710xxxx',
            'template_param' => [
                'coupon_code' => '',
                'exprise_date' => '',
            ]
        ],
    ],
那么我們就可以按一下調用優惠券的短信了ThinkAliSms::coupon('18759201xxx',['coupon_code'=>123456,'exprise_date'=>'2020-10-10']);更多詳情可以查看https://github.com/hbh112233abc/ali-sms
評論( 相關
后面還有條評論,點擊查看>>
养老时时彩计划软件