A Meteor wrapper for the MailChimp API.
See also these wrappers:
- node-mailchimp - A node.js wrapper for the MailChimp API
miro:mailchimp exposes MailChimp API v2.0 features to your Meteor application.
miro:mailchimp also provides one template you can use out of the box:
{{> MailChimpListSubscribe}}
, which you can use to enable your visitors to subscribe
to your mailing list(s).
Install using Meteor:
meteor add miro:mailchimp
Use in your template:
<div id="subscribeForm">
{{> MailChimpListSubscribe}}
</div>
Put in your server's settings.json:
{
"private": {
"MailChimp": {
"apiKey": "<Your MailChimp API Key>",
"listId": "<ID of your default mailing list>"
}
}
}
and start your server with:
meteor --settings settings.json
MailChimp takes two arguments. The first argument is your API key, which you can find in your MailChimp Account. The second argument is an options object which can contain the following option:
version
The API version to use. Defaults to 2.0.
All of the API categories and methods described in the MailChimp API v2.0 Documentation are available in this wrapper both server- and client-side.
To use them, the method call
is used which takes four parameters:
section
The section of the API method to call (e.g. 'campaigns').method
The method to call in the given section.params
Parameters to pass to the API method.callback
(optional server-side, required client-side) Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
NOTE: If
callback
is ommited server-side, the method runs "synchronously" viaMeteor.wrapAsync
method.
// You can as well pass different parameters on each call
var mailChimp = new MailChimp( /* apiKey, { version: '2.0' } */ );
mailChimp.call( 'campaigns', 'list', {
start: 0,
limit: 25
},
// Callback beauty in action
function ( error, result ) {
if ( error ) {
console.error( '[MailChimp][Campaigns][List] Error: %o', error );
} else {
// Do something with your data!
console.info( '[MailChimp][Campaigns][List]: %o', result );
}
}
);
// You can as well pass different parameters on each call
var mailChimp = new MailChimp( /* apiKey, { version: '2.0' } */ );
var result = mailChimp.call( 'campaigns', 'list', {
start: 0,
limit: 25
});
// Do something with your data!
console.info( '[MailChimp][Campaigns][List]: %o', result );
- Reinstated server-side callback in case someone still wants to use it instead
of
Meteor.wrapAsync
method (#19) - Updated documentation (README.md)
- Fixed bug with
Meteor.wrapAsync
not returning real error (#16) - Fixed bug with
audit-argument-checks
package throwing 'Did not check()' error (#15)
- Bumped version number
- README.md fix
- Update to Meteor v1.0
- Bug fixes
- Cleanup
- Fixed typo in README.md
- Updated README.md to reflect changes in v0.4.0
- Introduce settings.json for MailChimpOptions
- If already subscribed show different message then success message
- Enable submit with return key
- On client, MailChimp.call() now reads API Key from session variable 'MailChimpOptions.apiKey' as well
- Initial release
Copyright © 2014-1015 Miroslav Hibler
miro:mailchimp is licensed under the MIT license.