Fazland's Mailup Rest Client adalah klien PHP REST yang tidak resmi untuk email dan surat SMS GatewayProvider.
Metode instalasi yang disarankan adalah melalui komposer:
$ composer require fazland/mailup-rest-clientIni sangat sederhana. Pertama -tama, konfigurasi!
Parameter konfigurasi wajib adalah:
usernamepasswordclient_idclient_secret Satu -satunya parameter opsional adalah cache_dir . Jika diatur, token akses disimpan di jalur itu.
Cukup buat objek Context yang melewati konstruktor parameter sebagai array:
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 ); Untuk membuat MailingList Anda dapat mengikuti contoh ini. Tolong, lihat dokumen API resmi surat untuk array $params .
use Fazland MailUpRestClient MailingList ;
$ email = " [email protected] " ;
$ listName = " list_name " ;
$ params = [
// your params...
];
$ list = MailingList:: create ( $ context , $ listName , $ email , $ params ); Anda juga dapat memperoleh semua daftar yang ada di akun surat Anda dengan menghubungi Metode Statis MailingList::getAll() :
use Fazland MailUpRestClient MailingList ;
$ lists = MailingList:: getAll ( $ context ); Setelah Anda memiliki instance MailingList , Anda dapat melakukan operasi berikut:
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 melalui 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 ); Setiap MailingList dapat dibagi menjadi beberapa grup. Operasi yang tersedia adalah sebagai berikut:
$ 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 ();Kontribusi dipersilakan. Jangan ragu untuk membuka PR atau mengajukan masalah di sini di GitHub!
Klien mailup rest dilisensikan di bawah lisensi MIT - lihat file lisensi untuk detailnya