sliverwing / alidayu
Sliverwing Alidayu API
0.0.1
2016-12-17 01:57 UTC
Requires
- flc/alidayu: *
This package is not auto-updated.
Last update: 2024-09-29 02:23:51 UTC
README
用法
composer require sliverwing/alidayu
- 将
Sliverwing\Alidayu\AlidayuServiceProvider::class,
添加到您的config/app.php
文件中 php artisan vendor:publish --provider="Sliverwing\Alidayu\AlidayuServiceProvider"
- 编辑
config/alidayu.php
并添加您的 appkey 和 secretKey - 在
sms
数组中添加您的短信配置 - 编辑您的
.env
文件并确保您有正确的QUEUE_DRIVER
配置 - 在
.env
文件中添加ALIDAYU_APPKEY
和ALIDAYU_SECRET
php artisan queue:work
- 编辑您需要发送短信的控制器
use Sliverwing\Alidayu\Jobs\AlidayuMessageJob;
//... in some action
$this->dispatch(new AlidayuMessageJob($phoneNumber, $paramInYourTemplate, $configNameInAlidayuConfig));
- 然后您将在控制台看到结果
示例
- 我的
config/alidayu.php
看起来像这样
<?php
return [
'appkey' => env('ALIDAYU_APPKEY'),
'secretKey' => env('ALIDAYU_SECRET'),
'sms' => [
'numsend' => [
'SmsFreeSignName' => '医*',
'SmsTemplateCode' => 'SMS_3*******',
],
],
];
- 我的模板是
您的注册码为 ${code}
- 我可以通过以下方式发送我的验证码
$this->dispatch(new AlidayuMessageJob($phoneNumber, ['code'=>$code], "numsend"));