MailChimp API (v3) integration developed for YeahCoach project.
Use composer
to install the extension to your Yii2 installation.
The extension works as a standard Yii2 component.
To use it, just add and configure it inside the main.php
configuration array
(or wherever suitable for your setup), e.g.
'components' => [
// ...
'mailChimp' => [
'class' => 'dlds\mailchimp\YcMailChimp',
'apiKey' => 'a576b8adf6d34916d2f7eedf0eb4dd2f-us17',
'listId' => '123abc4560',
'categoryId' => 'def890abcd'
]
]
Required initial values are only class
and apiKey
, but it's recommended to specify all properties as shown
to avoid the need to pass them later (you can always override the default values and pass them as method parameters).
Example usage:
// load the component
$chimp = Yii::$app->mailChimp;
// get unsubscribed users on your MailChimp list
$resultObject = $chimp->getUnsubscribedContacts();
// print returned array of MailChimpBasicUser objects
print_r($resultObject->getData());
Codeception unit tests are included. From the root directory:
php ./vendor/bin/codecept run unit
- MailChimp API - simple MailChimp API wrapper (uses cURL for API calls)