ลูกค้า Skebby Rest ของ Fazland เป็นลูกค้า PHP REST ที่ไม่เป็นทางการสำหรับ SMS Gatewayprovider Skebby ของอิตาลี
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 ของคุณเป็นอาร์กิวเมนต์ที่สามของตัวสร้างลูกค้า:
$ dispatcher = new EventDispatcher (); // any dispatcher implementing EventDispatcherInterface
$ options = [ /* .. */ ]; // see above for detailed options
$ this -> skebbyRestClient = new Client ( $ options , null , $ dispatcher ); ทุกครั้งที่มีการส่ง SMS A FazlandSkebbyRestClientEventSmsMessageEvent จะถูกส่ง
วิ่ง
$ vendor/bin/phpunitยินดีต้อนรับการมีส่วนร่วม อย่าลังเลที่จะเปิดการประชาสัมพันธ์หรือยื่นปัญหาที่นี่ใน GitHub!
ไคลเอนต์ SKEBBY RES