skebby rest client
0.3.0
Fazland的Skebby Rest客户端是意大利SMS Gateway -Provider Skebby的非官方PHP REST客户端。
php > = 7.4php xml extensionsymfony/options-resolvergiggsey/libphonenumber-for-php > = 8.0 建议的安装方法是通过作曲家:
$ composer require fazland/skebby-rest-client这真的很简单。首先,配置!
强制配置参数是:
usernamepasswordsendermethod只需创建一个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,请按照以下示例:
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)方法发送SMS即可!
$ client -> send ( $ sms );单个客户端将通过您在配置中指定的方法发送SMS。如果要通过另一种方法发送它,只需创建一个新客户端即可。
只要它实现PSR-14,您就可以利用首选的事件系统。只需将调度程序作为客户端构造函数的第三个参数:
$ dispatcher = new EventDispatcher (); // any dispatcher implementing EventDispatcherInterface
$ options = [ /* .. */ ]; // see above for detailed options
$ this -> skebbyRestClient = new Client ( $ options , null , $ dispatcher );每次发送SMS时,都会派遣FazlandSkebbyRestClientEventSmsMessageEvent 。
跑步
$ vendor/bin/phpunit欢迎捐款。请随时在Github上打开PR或提交问题!
Skebby Rest客户端已根据MIT许可证获得许可 - 有关详细信息,请参见许可证文件