tomas-kulhanek / sms-manager
此包已被弃用且不再维护。未建议替代包。
通过 SmsManager.cz 发送短信的 PHP 库
v1.0.1
2021-08-26 22:38 UTC
Requires
- php: >=7.2
- ext-dom: *
- ext-libxml: *
- ext-simplexml: *
- consistence-community/consistence: ^2.1
- nyholm/psr7: ^1.4
- psr/http-client: ^1.0
Requires (Dev)
- php-http/httplug: ^2.2
- phpstan/phpstan: ^0.12.96
- phpstan/phpstan-phpunit: ^0.12.22
- phpstan/phpstan-strict-rules: ^0.12.11
- phpunit/phpunit: ^9.5
- symfony/http-client: ^5.3
README
用于通过 SmsManager.cz 网关发送短信消息的 PHP 库。(目前未实现所有 API 方法)
安装
composer require tomas-kulhanek/sms-manager
使用
在代码中使用 SmsManager
接口,例如。
public function __construct(SmsManager $smsManager) { ... }
并将 SMSManager 别名到 ApiSmsManager
用于您的生产使用。
Symfony 例子
services: TomasKulhanek\SmsManager\SmsManager: alias: TomasKulhanek\SmsManager\ApiSmsManager
要发送消息,创建新的 SmsMessage
$httpClient = new \Symfony\Component\HttpClient\HttplugClient(); // you can use any client for psr-7 $smsManager = new \TomasKulhanek\SmsManager\ApiSmsManager($httpClient); $smsMessage = new \TomasKulhanek\SmsManager\SmsMessage( 'message text', [ '+420777888999' ], \TomasKulhanek\SmsManager\RequestType::getRequestTypeLow(), // optional, defaults to High 'sender', // optional 1 // optional, CustomID ); $smsManager->send($smsMessage);
SmsMessage
的第三个参数是 RequestType,由 RequestType
类表示。例如,低请求类型通过 RequestType::getRequestTypeLow()
实例化。