Der Mailup Rest Client von Fazland ist ein inoffizieller PHP -REST -Client für die E -Mail- und SMS -GatewayProvider -Mailup.
Die vorgeschlagene Installationsmethode erfolgt über Komponist:
$ composer require fazland/mailup-rest-clientEs ist wirklich einfach. Erstens Konfiguration!
Die obligatorischen Konfigurationsparameter sind:
usernamepasswordclient_idclient_secret Der einzige optionale Parameter ist cache_dir . Wenn festgelegt, werden das Zugriffstoken auf diesem Weg gespeichert.
Erstellen Sie einfach ein Context , das die Parameter als Array an den Konstruktor übergibt:
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 ); Um eine MailingList zu erstellen, können Sie diesem Beispiel folgen. Bitte beachten Sie die offiziellen API -Dokumente von Mailups für das $params -Array.
use Fazland MailUpRestClient MailingList ;
$ email = " [email protected] " ;
$ listName = " list_name " ;
$ params = [
// your params...
];
$ list = MailingList:: create ( $ context , $ listName , $ email , $ params ); Sie können auch alle vorhandenen Listen in Ihrem Mailup -Konto erhalten, indem Sie die statische Methode MailingList::getAll() aufrufen:
use Fazland MailUpRestClient MailingList ;
$ lists = MailingList:: getAll ( $ context ); Sobald Sie eine Instanz von MailingList haben, können Sie folgende Vorgänge ausführen:
Recipient hinzu 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 entfernen use Fazland MailUpRestClient Recipient ;
$ list -> removeRecipient ( new Recipient ( ' Aragorn ' , ' [email protected] ' , ' 3333333333 ' , ' +39 ' ));Recipient per 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 ); Jede MailingList kann in mehrere Gruppen aufgeteilt werden. Die verfügbaren Operationen sind die folgenden:
$ 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 ();Beiträge sind willkommen. Fühlen Sie sich frei, eine PR zu öffnen oder hier auf Github ein Problem zu stellen!
Der Mailup -REST -Kunde ist unter der MIT -Lizenz lizenziert - finden Sie in der Lizenzdatei Details