台灣簡訊 twsms api 客戶端
v1.0.7
2022-12-06 10:05 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-18 10:58:11 UTC
README
此包裝使得使用 Laravel 5.3+ 通過 [twsms]發送通知變得更加容易。
內容
安裝
您可以使用 composer 安裝此包裝
composer require taiwan-sms/twsms illuminate/notifications php-http/guzzle6-adapter
然後您必須安裝服務提供者
// config/app.php 'providers' => [ ... TaiwanSms\TwSMS\TwSMSServiceProvider::class, ],
設置 TwSMS 服務
將您的 TwSMS 登錄名、秘密鍵(哈希密碼)和默認發送者名稱(或電話號碼)添加到您的 config/services.php
// config/services.php ... 'twsms' => [ 'username' => env('SERVICES_TWSMS_USERNAME'), 'password' => env('SERVICES_TWSMS_PASSWORD'), ], ...
使用方法
您可以在通知內部的 via()
方法中使用該通道
use TaiwanSms\TwSMS\TwSMSMessage; use TaiwanSms\TwSMS\TwSMSChannel; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [TwSMSChannel::class]; } public function toTwSMS($notifiable) { return TwSMSMessage::create("Task #{$notifiable->id} is complete!"); } }
在您的可通知模型中,請確保包含 routeNotificationForTwSMS() 方法,该方法返回電話號碼。
public function routeNotificationForTwSMS() { return $this->phone; }
可用的方法
content()
:設置通知消息的內容。
sendTime()
:設置通知消息的發送時間。
變更記錄
請參考 變更記錄 以了解最近有哪些變化。
測試
$ composer test
安全性
如果您發現任何安全相關問題,請發送電子郵件至 recca0120@gmail.com,而不是使用問題追蹤器。
貢獻
請參考 貢獻指南 以获取详细信息。
致謝
版權
MIT 协議(MIT)。請參考 版權文件 以获取更多信息。
僅限 API
composer require taiwan-sms/twsms php-http/guzzle6-adapter
使用方法
require __DIR__.'/vendor/autoload.php'; use TaiwanSms\TwSMS\Client; $userId = 'xxx'; $password = 'xxx'; $client = new Client($userId, $password); var_dump($client->credit()); // 取得額度 var_dump($client->send([ 'to' => '09xxxxxxxx', 'text' => 'test message', ])); /* return [ 'code' => '00000', 'text' => 'Success', 'msgid' => '265078525', ]; */