recca0120 / every8d
v1.1.3
2020-05-14 16:24 UTC
Requires
- php: >=5.5.9
- guzzlehttp/psr7: ^1.4
- nesbot/carbon: ^1.22|^2.0
- php-http/client-implementation: ^1.0|^2.0
- php-http/discovery: ^1.2
- php-http/httplug: ^1.1|^2.0
- php-http/message: ^1.5
Requires (Dev)
- illuminate/support: ^5.1
- mockery/mockery: ~0.9.4|~1.0
- php-http/guzzle6-adapter: ^1.1|^2.0
- phpunit/phpunit: ~4.8|~5.4|~6.1|~7.0
Suggests
- illuminate/notifications: If you need Laravel Notification
README
此包使用 [every8d] 在 Laravel 5.3+ 中发送通知变得简单。
内容
安装
您可以通过 composer 安装此包
composer require recca0120/every8d illuminate/notifications php-http/guzzle6-adapter
然后您必须安装服务提供者
// config/app.php 'providers' => [ ... Recca0120\Every8d\Every8dServiceProvider::class, ],
设置 Every8d 服务
将您的 Every8d 登录、密钥(哈希密码)和默认发送者名称(或电话号码)添加到您的 config/services.php
// config/services.php ... 'every8d' => [ 'user_id' => env('SERVICES_EVERY8D_USER_ID'), 'password' => env('SERVICES_EVERY8D_PASSWORD'), ], ...
用法
您可以在通知内的 via()
方法中使用该频道
use Recca0120\Every8d\Every8dMessage; use Recca0120\Every8d\Every8dChannel; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [Every8dChannel::class]; } public function toEvery8d($notifiable) { return Every8dMessage::create("Task #{$notifiable->id} is complete!"); } }
在您的可通知模型中,确保包含一个 routeNotificationForEvery8d() 方法,该方法返回电话号码。
public function routeNotificationForEvery8d() { return $this->phone; }
可用方法
subject()
: 设置通知主题的标题。
content()
: 设置通知消息的内容。
sendTime()
: 设置通知消息的发送时间。
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
测试
$ composer test
安全
如果您发现任何安全相关的问题,请通过电子邮件 recca0120@gmail.com 而不是使用问题跟踪器。
贡献
有关详细信息,请参阅 CONTRIBUTING。
致谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。
仅 API
composer require recca0120/every8d php-http/guzzle6-adapter
如何使用
require __DIR__.'/vendor/autoload.php'; use Recca0120\Every8d\Client; $userId = 'xxx'; $password = 'xxx'; $client = new Client(userId, $password); $client->credit(); // 取得額度 var_dump($client->send([ 'to' => '09xxxxxxxx', 'text' => 'test message', ])); /* return [ 'credit' => 100.0, 'sended' => 1, 'cost' => 1.0, 'unsend' => 0, 'batchId' => 'd0ad6380-4842-46a5-a1eb-9888e78fefd8', ]; */