Skip to content

vojtabiberle/mailchimp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailchimp API v3 PHP client

Unoficial Mailchimp API v3 PHP client library

This library is under development

  • even not every endpoints are implemented yet (but you can help me! its easy!)

Usage

Get data

$client = new Mailchimp\Client('YOUR-API-KEY-HERE');

$accountDetails = $client->getAccountDetails();

$subscriberListCollection = $client->getLists();

$subscriberList = $client->getList(LIST_ID);

$member1 = $client->getMember(LIST_ID, md5(TEST_EMAIL)); //use API search

$members = $subscriberList->getMembers();

$member2 = $members->findMembers(['email_address' => TEST_EMAIL]); //filter in memory

Create new data

$client = new Mailchimp\Client('YOUR-API-KEY-HERE');

/**
 * This is factory method for Messages.
 * You can create new message like: new Members($client->getWorker());
 */
/**
 * @var Mailchimp\Message\Members $newMember
 */
$newMember = $client->createMessage('Members');

$newMember->setEmailAddress(TEST_EMAIL2);
$newMember->setStatus('subscribed');

$reallyNewMember = $members->create($newMember); //returns same object but with new data from API

Update and delete data

$client = new Mailchimp\Client('YOUR-API-KEY-HERE');

/**
 * @var Mailchimp\Message\Members $member3
 */
$member3 = $client->getMember(LIST_ID, md5(TEST_EMAIL2));

$member3->setVip(true);
$member3->setLanguage('cs');
$member3->update(); //send PATCH request

$member3->delete(); //send DELETE request

If something goes wrong, client throw Exceptions. Look into code ;-)

About

Unoficial Mailchimp v3 API library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published