songshenzong / aliyun-dysms
a extension Aliyun SMS SDK
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 2 792
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.32
Requires (Dev)
- laravel/framework: 5.6.*
- phpunit/phpunit: ~7.0
This package is not auto-updated.
Last update: 2019-02-28 08:27:21 UTC
README
Installation
Require this package with composer:
composer require songshenzong/aliyun-dysms
Settings
/** * If Laravel, Please write these fields in the `env` file */ ALIYUN_DYSMS_KEY=yourAccessKeyId ALIYUN_DYSMS_SECRET=yourAccessKeySecret ALIYUN_DYSMS_SIGN=yourSignName /** * If not Laravel, You have to run these methods first. */ AliyunSms::setAccessKeyId('yourAccessKeyId'); AliyunSms::setAccessKeySecret('yourAccessKeySecret'); AliyunSms::setSignName('yourSignName');
Send SMS
// Send SMS without `SignName` if used `setSignName`. $response = AliyunSms::sendSms('18888888888', 'SMS_12345678', ['code' => 12345]); // Send in bulk, no more than 1000 phone numbers. $response = AliyunSms::sendSms('18888888888,17777777777', 'SMS_12345678', ['code' => 12345]); $response = AliyunSms::sendBatchSms(['1500000000', '1500000001'], ['云通信', '云通信'], 'SMS_12345678', [['code' => '123'], ['code' => '456']]); // Get Result if (AliyunSms::ok($response)) { echo 'OK'; } else { echo 'Failed'; }
Laravel Artisan
Publish configuration files. If not, They can not be serialized correctly when you execute the config:cache
Artisan command.
php artisan vendor:publish --provider="Songshenzong\AliyunSms\ServiceProvider"
Laravel Queues
AliyunSendSmsJob::dispatch('18888888888', "SMS_12345678", ['code' => 520])->onQueue('sms'); AliyunSendSmsJob::dispatchNow('18888888888', "SMS_12345678", ['code' => 520]);
Laravel Notifications
/** * Get the notification's delivery channels. * * @param $notifiable * * @return array */ public function via($notifiable): array { return [AliyunBatchSmsChannel::class, AliyunSmsChannel::class]; } /** * @param $notifiable * * @return mixed */ public function toAliyunSMS($notifiable) { return AliyunSms::sendSms('18888888888', 'SMS_12345678', ['code' => 12345]); } /** * @param $notifiable * * @return mixed */ public function toAliyunBatchSMS($notifiable) { return AliyunSms::sendBatchSms(['1500000000', '1500000001'], ['云通信', '云通信'], 'SMS_12345678', [['code' => '123'], ['code' => '456']]); }
More Usage
See: https://help.aliyun.com/document_detail/55359.html
Documentation
Please refer to our extensive Wiki documentation for more information.
Support
For answers you may not find in the Wiki, avoid posting issues. Feel free to ask for support on Songshenzong.com
License
This package is licensed under the BSD 3-Clause license.