fazland/ skebby-rest-client
非官方Skebby Rest客户端
0.3.0
2021-03-15 10:28 UTC
Requires
- php: >=7.0
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- giggsey/libphonenumber-for-php: ^7.0|^8.0
- psr/event-dispatcher: ^1.0
- symfony/options-resolver: ^2.7|^3.0|^4.0|^5.0
Requires (Dev)
- ext-curl: *
- guzzlehttp/guzzle: ^6.0
- kcs/function-mock: dev-master
- php-http/discovery: ^1.0
- php-http/guzzle6-adapter: ^1.1,>=1.1.1
- php-http/httplug: ^1.0
- php-http/message: ^1.4
- php-http/message-factory: ^1.0
- phpunit/phpunit: ^6.5
- symfony/event-dispatcher: ^2.7|^3.0|^4.0|^5.0
This package is auto-updated.
Last update: 2024-09-18 17:22:32 UTC
README
Fazland的Skebby Rest客户端是意大利短信网关服务提供商Skebby的非官方PHP Rest客户端。
要求
php
>= 7.4php xml扩展
symfony/options-resolver
giggsey/libphonenumber-for-php
>= 8.0
安装
建议的安装方法是使用composer
$ composer require fazland/skebby-rest-client
使用Skebby Rest客户端
非常简单。首先,配置!
配置
必须的配置参数包括
用户名
密码
发送者
方法
只需创建一个Client
对象,将参数作为数组传递给构造函数
$this->skebbyRestClient = new Client([ 'username' => 'your_username', 'password' => 'your_password', 'sender' => '+393333333333', 'method' => SendMethods::CLASSIC, 'encoding_scheme' => EncodingSchemas::NORMAL, // Optional 'charset' => Charsets::UTF8, // Optional 'endpoint_uri' => 'https://gateway.skebby.it/api/send/smseasy/advanced/rest.php' // (default) ]);
您还可以为delivery_start
和validity_period
设置默认值,这样它们可以被Sms对象覆盖
创建短信
要创建短信,请遵循以下示例
Sms::create() ->setRecipients([ '+393473322444', '+393910000000' ]) ->setRecipientVariables('+393473322444', [ 'name' => 'Mario', 'quest' => 'Go and rescue Peach, Bowser kidnapped her!' ]) ->setRecipientVariables('+393910000000', [ 'name' => 'Luigi', 'quest' => 'Help Mario, Bowser is really bad!!' ]) ->setText('Hey ${name}! ${quest}') ;
发送短信!
只需使用Client::send(Sms $sms)
方法发送短信!
$client->send($sms);
注意
单个客户端将通过配置中指定的方法发送短信。如果您想通过另一个方法发送,只需创建一个新的客户端。
事件
只要它实现了PSR-14,您就可以利用您喜欢的任何事件系统。只需将您的调度器作为第三个参数传递给Client构造函数
$dispatcher = new EventDispatcher(); // any dispatcher implementing EventDispatcherInterface $options = [/* .. */]; // see above for detailed options $this->skebbyRestClient = new Client($options, null, $dispatcher);
每次发送短信时,都会分发一个\Fazland\SkebbyRestClient\Event\SmsMessageEvent
。
测试
运行
$ vendor/bin/phpunit
贡献
欢迎贡献。请随意在此GitHub上打开PR或提交问题!
许可
Skebby Rest Client遵循MIT许可 - 请参阅LICENSE文件以获取详细信息