El cliente de REST de Mailup de Fazland es un cliente PHP REST no oficial para el correo electrónico y SMS GatewayProvider Mailup.
El método de instalación sugerido es a través del compositor:
$ composer require fazland/mailup-rest-clientEs realmente simple. En primer lugar, configuración!
Los parámetros de configuración obligatorios son:
usernamepasswordclient_idclient_secret El único parámetro opcional es cache_dir . Si se establece, el token de acceso se guarda en ese camino.
Simplemente cree un objeto Context que pasa al constructor los parámetros como una matriz:
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 ); Para crear una MailingList puede seguir este ejemplo. Por favor, consulte los documentos de API oficiales de Mailup para la matriz $params .
use Fazland MailUpRestClient MailingList ;
$ email = " [email protected] " ;
$ listName = " list_name " ;
$ params = [
// your params...
];
$ list = MailingList:: create ( $ context , $ listName , $ email , $ params ); También puede obtener todas las listas existentes en su cuenta de correo llamando al método estático MailingList::getAll() ::
use Fazland MailUpRestClient MailingList ;
$ lists = MailingList:: getAll ( $ context ); Una vez que tenga una instancia de MailingList , puede hacer las siguientes operaciones:
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 por su 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 ); Cada MailingList se puede dividir en múltiples grupos. Las operaciones disponibles son las siguientes:
$ 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 ();Las contribuciones son bienvenidas. ¡No dude en abrir un PR o presentar un problema aquí en GitHub!
El cliente de REST de Mailup tiene licencia bajo la licencia MIT; consulte el archivo de licencia para obtener más detalles