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許可證獲得許可 - 有關詳細信息,請參見許可證文件