mailup rest client
1.0.0
FazlandのMailup Rest Clientは、電子メールおよびSMS GatewayProvider Mailup用の非公式のPHP RESTクライアントです。
推奨されるインストール方法は、作曲家経由です。
$ 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を作成するには、この例に従うことができます。 $paramsアレイについては、mailupの公式APIドキュメントを参照してください。
use Fazland MailUpRestClient MailingList ;
$ email = " [email protected] " ;
$ listName = " list_name " ;
$ params = [
// your params...
];
$ list = MailingList:: create ( $ context , $ listName , $ email , $ params ); Static Method 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 ' ));emailでRecipientを見つけます $ 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 ();貢献は大歓迎です。 PRを開いたり、GitHubで問題を提出したりしてください!
Mailup RESTクライアントはMITライセンスに基づいてライセンスされています - 詳細については、ライセンスファイルを参照してください