ไคลเอนต์ Mailup Rest ของ Fazland เป็นไคลเอนต์ PHP REST ที่ไม่เป็นทางการสำหรับอีเมลและ SMS GatewayProvider Mailup
วิธีการติดตั้งที่แนะนำคือผ่านนักแต่งเพลง:
$ composer require fazland/mailup-rest-clientมันง่ายจริงๆ ก่อนอื่นการกำหนดค่า!
พารามิเตอร์การกำหนดค่าบังคับคือ:
usernamepasswordclient_idclient_secret พารามิเตอร์เสริมเท่านั้นคือ cache_dir หากตั้งค่าโทเค็นการเข้าถึงจะถูกบันทึกไว้ในเส้นทางนั้น
เพียงสร้างวัตถุ Context ที่ส่งผ่านไปยังตัวสร้างพารามิเตอร์เป็นอาร์เรย์:
use Fazland MailUpRestClient Context ;
$ config = [
' username ' => ' your_username ' ,
' password ' => ' your_password ' ,
' client_id ' => ' your_client_id ' ,
' client_secret ' => ' your_client_secret ' ,
' cache_dir ' => ' path_to_your_cache_dir ' , // Optional
];
$ httpClient = new HttpClientImplementation ();
$ context = new Context ( $ config , $ httpClient ); ในการสร้าง MailingList คุณสามารถทำตามตัวอย่างนี้ โปรดดูเอกสาร API อย่างเป็นทางการของ Mailup Mailup สำหรับอาร์เรย์ $params
use Fazland MailUpRestClient MailingList ;
$ email = " [email protected] " ;
$ listName = " list_name " ;
$ params = [
// your params...
];
$ list = MailingList:: create ( $ context , $ listName , $ email , $ params ); นอกจากนี้คุณยังสามารถรับรายการที่มีอยู่ทั้งหมดในบัญชี MailUp ของคุณได้โดยเรียกวิธีการ MailingList::getAll() :
use Fazland MailUpRestClient MailingList ;
$ lists = MailingList:: getAll ( $ context ); เมื่อคุณมีอินสแตนซ์ของ MailingList คุณสามารถดำเนินการต่อไปนี้:
Recipient use Fazland MailUpRestClient Recipient ;
$ list -> addRecipient ( new Recipient ( ' Aragorn ' , ' [email protected] ' , ' 3333333333 ' , ' +39 ' ));Recipient use Fazland MailUpRestClient Recipient ;
$ list -> updateRecipient ( new Recipient ( ' Aragorn ' , ' [email protected] ' , ' 3334444444 ' , ' +39 ' ));Recipient use Fazland MailUpRestClient Recipient ;
$ list -> removeRecipient ( new Recipient ( ' Aragorn ' , ' [email protected] ' , ' 3333333333 ' , ' +39 ' ));Recipient ทาง email $ recipient = $ list -> findRecipient ( ' [email protected] ' ); // null returned if current email was not found $ groups = $ list -> getGroups (); $ countRecipients = $ list -> countRecipients (); // equal to $list->countRecipients(Recipient::STATUS_SUBSCRIBED);
// OR
$ countRecipients = $ list -> countRecipients (Recipient:: STATUS_UNSUBSCRIBED );
// OR
$ countRecipients = $ list -> countRecipients (Recipient:: STATUS_PENDING ); $ recipients = $ list -> getRecipientsPaginated ( $ pageNumber , $ pageSize );Recipient : $ list -> import ( $ recipients ); MailingList แต่ละรายการสามารถแบ่งออกเป็นหลายกลุ่ม การดำเนินการที่มีอยู่มีดังต่อไปนี้:
$ group -> getName ();
$ group -> setName ( ' Gondor Army ' ); $ group -> getNotes ();
$ group -> setNotes ( ' 10.000 knights and 20.000 peons ' ); $ group -> isDeletable ();
$ group -> setDeletable ( true ); $ group -> delete (); use Fazland MailUpRestClient Recipient ;
$ legolas = new Recipient ( ' Legolas Thranduilion ' , ' [email protected] ' , ' 3334444444 ' , ' +39 ' );
$ group -> addRecipient ( $ legolas );
$ group -> removeRecipient ( $ legolas );
$ lothlorienCitizens = $ group -> getRecipients ();ยินดีต้อนรับการมีส่วนร่วม อย่าลังเลที่จะเปิดการประชาสัมพันธ์หรือยื่นปัญหาที่นี่ใน GitHub!
ไคลเอน