nanopkg / laravel-bulk-sms-bd
使用本包,您可以轻松地将Bangladesh的bulksmsbd.com API集成到您的项目中,以实现批量短信系统。
2.0.0
2023-01-09 05:53 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.5
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-09 11:49:49 UTC
README
使用本包,您可以轻松地将Bangladesh的bulksmsbd.com API集成到您的项目中,以实现批量短信系统。
安装
您可以通过Composer安装此包
composer require nanopkg/laravel-bulk-sms-bd
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="bulk-sms-bd-config"
这是发布配置文件的内容
return [ /* |-------------------------------------------------------------------------- | Laravel Bulk SMS BD Mode of sending sms |-------------------------------------------------------------------------- | | This value is the mode of your laravel-bulk-sms-bd api integration. | log: for testing purpose | live: for live sms sending | */ 'mode' => env('BULK_SMS_BD_MODE', 'log'), /* |-------------------------------------------------------------------------- | Laravel Bulk SMS BD Api Key |-------------------------------------------------------------------------- | | This value is the api key of your laravel-bulk-sms-bd api integration. | */ 'api_key' => env('BULK_SMS_BD_API_KEY', ''), /* |-------------------------------------------------------------------------- | Laravel Bulk SMS BD Sender ID |-------------------------------------------------------------------------- | | This value is the Sender ID of your laravel-bulk-sms-bd api integration. | */ 'sender_id' => env('BULK_SMS_BD_SENDER_ID', ''), /* |-------------------------------------------------------------------------- | Laravel Bulk SMS BD Api Url |-------------------------------------------------------------------------- | | This value is the Api Url of your laravel-bulk-sms-bd api integration. | */ 'base_uri' => env('BULK_SMS_BD_API_URL', 'https://bulksmsbd.net/api/'), /* |-------------------------------------------------------------------------- | Laravel Bulk SMS BD Api Url SSL VERIFY |-------------------------------------------------------------------------- | | This value is the Api Url SSL verify of your laravel-bulk-sms-bd api integration. | */ 'verify' => env('BULK_SMS_BD_API_URL_VERIFY', false), /* |-------------------------------------------------------------------------- | Laravel Bulk SMS BD Log |-------------------------------------------------------------------------- | | This value is the log of your laravel-bulk-sms-bd api integration. | */ 'log' => [ 'driver' => env('BULK_SMS_BD_LOG_DRIVER', 'single'), 'path' => env('BULK_SMS_BD_LOG_PATH', storage_path('logs/laravel-bulk-sms-bd-log.log')), ], /* |-------------------------------------------------------------------------- | Laravel Bulk SMS BD Notification Keys |-------------------------------------------------------------------------- | | This value is the Notification Keys of your laravel-bulk-sms-bd api integration. | */ 'notification' => [ // define your custom notification key for message 'message' => 'message', // define your custom notification key for mobile number 'contacts' => 'to', ], ];
将以下条目添加到您的.env文件中
// This value is the mode of your laravel-bulk-sms-bd api integration. | log: for testing purpose | live: for live sms sending BULK_SMS_BD_MODE='log' // This value is the api key of your laravel-bulk-sms-bd api integration. BULK_SMS_BD_API_KEY='' // This value is the Sender ID of your laravel-bulk-sms-bd api integration. BULK_SMS_BD_SENDER_ID='' // This value is the Api Url SSL verify of your laravel-bulk-sms-bd api integration. BULK_SMS_BD_API_URL_VERIFY=false
用法
获取短信网关余额
按照以下步骤获取短信网关余额:
use Nanopkg\BulkSmsBd\Facades\BulkSmsBd; // get gateway balance $response = BulkSmsBd::getBalance(); return $response->balance;
发送一对一短信
按照以下步骤发送一对一短信:
use Nanopkg\BulkSmsBd\Facades\BulkSmsBd; // send one to one sms BulkSmsBd::oneToOne('017xxxxxxxx', 'আমার সোনার বাংলা, আমি তোমার ভালোবাসি।')->send();
如果您想通过队列发送短信,则请按照以下步骤操作,而不是上述方法。
use Nanopkg\BulkSmsBd\Jobs\BulkSmsBdOneToOne; // send one to one sms BulkSmsBdOneToOne::dispatch('017xxxxxxxx', 'আমার সোনার বাংলা, আমি তোমার ভালোবাসি।');
发送一对多短信
按照以下步骤发送一对多短信:
use Nanopkg\BulkSmsBd\Facades\BulkSmsBd; // Send one to many sms BulkSmsBd::oneToMany(['017xxxxxxxx','018xxxxxxxx','019xxxxxxxx'], 'আমার সোনার বাংলা, আমি তোমার ভালোবাসি।')->send();
如果您想通过队列发送短信,则请按照以下步骤操作,而不是上述方法。
use Nanopkg\BulkSmsBd\Jobs\BulkSmsBdOneToMany; // Send one to many sms BulkSmsBdOneToMany::dispatch(['017xxxxxxxx','018xxxxxxxx','019xxxxxxxx'], 'আমার সোনার বাংলা, আমি তোমার ভালোবাসি।');
发送多对多短信
按照以下步骤发送多对多短信:
use Nanopkg\BulkSmsBd\Facades\BulkSmsBd; // Send one to many sms BulkSmsBd::manyToMany([ [ 'to' => '017xxxxxxxx', 'message' => 'আমার সোনার বাংলা।' ], [ 'to' => '018xxxxxxxx', 'message' => 'আমি তোমার ভালোবাসি।' ], ])->send();
如果您想通过队列发送多对多短信,则请按照以下步骤操作,而不是上述方法。
use Nanopkg\BulkSmsBd\Jobs\BulkSmsBdManyToMany; // Send one to many sms BulkSmsBdManyToMany::dispatch([ [ 'to' => '017xxxxxxxx', 'message' => 'আমার সোনার বাংলা।' ], [ 'to' => '018xxxxxxxx', 'message' => 'আমি তোমার ভালোবাসি।' ] ]);
通过通知发送短信
按照以下步骤发送多对多短信:
use Nanopkg\BulkSmsBd\Broadcasting\BulkSmsBdChannel; /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [BulkSmsBdChannel::class]; } /** * Get the BulkSmsBd representation of the notification. * @param mixed $notifiable * @return array */ public function toBulkSmsBd($notifiable) { return [ 'message' => 'আমার সোনার বাংলা, আমি তোমায় ভালোবাসি', 'to' => $notifiable->phone, ]; }
如果您想自定义通知表示键,请打开bulksmsbd配置文件并修改通知消息和联系人值。
'notification' => [ // define your custom notification key for message 'message' => 'message', // define your custom notification key for mobile number 'contacts' => 'to', ],
测试
composer test
变更日志
请参阅CHANGELOG以获取有关最近更改的更多信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全漏洞
请参阅我们的安全策略以了解如何报告安全漏洞。
鸣谢
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。