bundana / services
API 服务列表,例如 SMS、WhatsApp、邮件等,用于开发。
v1.0.1
2024-02-29 13:41 UTC
This package is auto-updated.
Last update: 2024-09-29 14:58:23 UTC
README
Bundana Laravel 增值服务包是一个 Laravel 服务,用于通过 Hubtel 和 Mnotify 发送 SMS,以及使用 Paystack、Hubtel API 接收消息。
安装
要安装此包,您可以使用 Composer。在您的终端中运行以下命令:
composer require bundana/services
安装后,将服务提供者添加到您的 config/app.php 文件中
'providers' => [ // ... \Bundana\Services\BundanaServiceProvider::class,
发布包配置文件
php artisan vendor:publish --provider="Bundana\Services\Messaging\BundanaServiceProvider" --tag="config"
这将在您的 laravel 项目的 config 文件夹中创建一个 bundana-config.php
文件,您可以在其中设置您的 Mnotify API 密钥。现在我们已经向应用程序发布了几个新文件,我们需要使用以下命令重新加载它们
$ composer dump-autoload
配置
您需要使用您的 Mnotify、Hubtel 和 Paystack API 密钥配置此包。打开 .env
文件并添加以下值
MNOTIFY_API_KEY=
:您的 Mnotify API 密钥。MNOTIFY_SENDER_ID=
:您的 Mnotify 发送者 ID。MNOTIFY_API_KEY_V2=
:您的 Mnotify V2 API 密钥。MNOTIFY_SENDER_ID_V2=
:您的 Mnotify 发送者 ID。
如果使用 Hubtel 支付网关,请添加 Hubtel 凭据
HUBTEL_API_KEY=your_Hubtel_API_key
HUBTEL_API_SECRET=your_Hubtel_API_secret
如果使用 Paystack,请添加 Paystack 凭据
PAYSTACK_PUBLIC_KEY=your_Paystack_public_key
PAYSTACK_SECRET_KEY=your_Paystack_secret_key
另外,如果您计划使用 Hubtel 支付网关,请提供所需的凭据。
使用方法
通过 Mnotify 发送 SMS
要发送 SMS,您可以使用 Mnotify
类。以下是一个示例
use Bundana\Services\Messaging\Mnotify; Mnotify::to('recipient_phone_number') ->message('Your SMS message goes here') ->send();
使用 Mnotify API 的第 2 版发送 sms
Mnotify::to('recipient_phone_number') ->message('Your SMS message goes here') ->send('v2');
使用新的发送者 ID 和 API 密钥发送 SMS
Mnotify::to('recipient_phone_number') ->message('Your SMS message goes here') ->newKeys(['apiKey' => 'ss', 'sender_id' =>'ss']) ->send();
通过 Mnotify 发送批量 SMS
要发送批量 SMS,请使用 sendBulk
方法
use Bundana\Services\Messaging\Mnotify; $contactsAndMessages = [ 'recipient1' => 'message1', 'recipient2' => 'message2', ]; $responses = Mnotify::sendBulk($contactsAndMessages);
使用 Mnotify SMS API 的第 2 版发送批量 sms
use Bundana\Services\Messaging\Mnotify; $contactsAndMessages = [ 'recipient1' => 'message1', 'recipient2' => 'message2', ]; $responses = Mnotify::sendBulk($contactsAndMessages, 'v2');
检查 Mnotify SMS 余额
要检查 SMS 余额
use Bundana\Services\Messaging\Mnotify; // For version 1 $response = Mnotify::checkSMSBalance(); // For version 2 $response = Mnotify::checkSMSBalance('v2');
许可证
此包是开源软件,许可协议为 MIT 许可。