台湾短信 / every8d
every8d 短信 API 客户端
v1.1.5
2022-12-06 10:04 UTC
Requires
- php: >=5.5.9
- nesbot/carbon: ^1.22|^v2.0
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.2
- php-http/httplug: ^1.1|^2.0
- php-http/message: ^1.5
Requires (Dev)
- illuminate/config: ^5.1|^6.0|^7.0|^8.0|^9.0
- illuminate/container: ^5.1|^6.0|^7.0|^8.0|^9.0
- illuminate/notifications: ^5.1|^6.0|^7.0|^8.0|^9.0
- illuminate/queue: ^5.1|^6.0|^7.0|^8.0|^9.0
- illuminate/support: ^5.1|^6.0|^7.0|^8.0|^9.0
- mockery/mockery: ^1.0
- phpunit/phpunit: ~4.8|~5.4|~6.1|^8.5|^9.5
- roave/security-advisories: dev-latest
Suggests
- illuminate/notifications: If you need Laravel Notification
This package is auto-updated.
Last update: 2024-09-06 14:10:57 UTC
README
此包使用 [every8d] 和 Laravel 5.3+ 简化发送通知的过程。
内容
安装
您可以通过 composer 安装此包
composer require taiwan-sms/every8d illuminate/notifications php-http/guzzle6-adapter
然后您必须安装服务提供者
// config/app.php 'providers' => [ ... TaiwanSms\Every8d\Every8dServiceProvider::class, ],
设置 Every8d 服务
将您的 Every8d 登录、密钥(散列密码)和默认发送者名称(或电话号码)添加到您的 config/services.php
// config/services.php ... 'every8d' => [ 'user_id' => env('SERVICES_EVERY8D_USER_ID'), 'password' => env('SERVICES_EVERY8D_PASSWORD'), 'sms_host' => env('SERVICES_EVERY8D_SMS_HOST') ], ...
用法
您可以在通知中的 via()
方法中使用该通道
use TaiwanSms\Every8d\Every8dMessage; use TaiwanSms\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 taiwan-sms/every8d php-http/guzzle6-adapter
如何使用
require __DIR__.'/vendor/autoload.php'; use TaiwanSms\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', ]; */