therealsmat / laravel-ebulksms
:围绕 e-bulk sms api 的 Laravel 封装器
1.0.1
2018-01-12 21:37 UTC
Requires
- php: ~5.6|~7.0
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ~5.1
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2024-09-29 06:08:49 UTC
README
一个构建以允许尼日利亚 Laravel 开发者轻松从应用程序中发送短信的包。
要求
安装
您需要拥有 Ebulk 账户才能使用此包。如果您没有,请点击此处。
使用 composer 安装包。
$ composer require therealSMAT/laravel-ebulksms
如果您的 Laravel 版本低于 5.5,您可能需要将 therealsmat\Ebulksms\EbulkSmsServiceProvider::class,
添加到 config/app.php
中的 providers 数组。
Laravel 5.5 使用包自动发现,因此不需要您手动添加 ServiceProvider。
配置
使用以下命令发布配置文件:php artisan vendor:publish --provider="therealsmat\Ebulksms\EbulkSmsServiceProvider"
您将在配置目录中获得一个名为 ebulksms.php
的配置文件。根据您的 ebulk sms 设置自定义默认值。
<?php return [ /** * Your login username on eBulkSMS (same as your email address) */ 'username' => getenv('EBULK_USERNAME'), /** * Your Ebulk SMS Api Key */ 'apiKey' => getenv('EBULK_API_KEY'), /** * Your chosen sender name */ 'sender' => getenv('EBULK_SENDER_NAME'), /** * Country code to be appended to each phone number */ 'country_code' => '234' ];
用法
将以下内容添加到您的 .env 文件中
EBULK_USERNAME=*********** EBULK_API_KEY=************ EBULK_SENDER_NAME=********
创建一个路由端点
Route::get('/sms', 'HomeController@index');
短信
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use therealsmat\Ebulksms\EbulkSMS; class HomeController extends Controller { public function index(EbulkSMS $sms) { $message = 'Hello world!'; $recipients = '0701********'; return $sms->composeMessage($message) ->addRecipients($recipients) ->send(); } }
闪信
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use therealsmat\Ebulksms\EbulkSMS; class HomeController extends Controller { public function index(EbulkSMS $sms) { $message = 'Hello world!'; $recipients = '0701********'; return $sms->composeMessage($message) ->addRecipients($recipients) ->flash(); } }
余额查询
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use therealsmat\Ebulksms\EbulkSMS; class HomeController extends Controller { public function index(EbulkSMS $sms) { return $sms->getBalance(); } }
许可
MIT 许可证 (MIT)。有关更多信息,请参阅许可文件。