Skip to content

longxiao/aliyun-dysms

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

![来源]

Build Status Total Downloads Latest Stable Version License PHP Version

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.

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%