skebby rest client
0.3.0
FazlandのSkebby Restクライアントは、イタリアのSMS GatewayProvider Skebbyの非公式のPHPレストクライアントです。
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を実装する限り、優先イベントシステムを活用できます。クライアントコンストラクターの3番目の引数としてディスパッチャーを渡すだけです。
$ 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貢献は大歓迎です。 PRを開いたり、GitHubで問題を提出したりしてください!
Skebby RestクライアントはMITライセンスの下でライセンスされています - 詳細については、ライセンスファイルを参照してください