nanopkg/laravel-bulk-sms-bd

使用本包,您可以轻松地将Bangladesh的bulksmsbd.com API集成到您的项目中,以实现批量短信系统。


README

使用本包,您可以轻松地将Bangladesh的bulksmsbd.com API集成到您的项目中,以实现批量短信系统。

Latest Version on Packagist Issues GitHub Tests Action Status Total Downloads License

安装

您可以通过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)。有关更多信息,请参阅许可文件