MailChimp Lists - the Meteor way.
See also these wrappers:
- miro:mailchimp - A Meteor wrapper for the MailChimp API
miro:mailchimp-lists helps you to manage mailing lists.
Further information on the MailChimp API and its features is available at https://github.com/gomfunkel/node-mailchimp.
miro:mailchimp-lists also exposes one template you can use out of the box:
{{> MailChimpLists}}
, which will render all mailing lists for a given API Key.
Install using Meteor:
meteor add miro:mailchimp-lists // It will add miro:mailchimp package
// if not not already installed
Use in your template:
<div id="mailChimpLists">
<!-- There's also another utility template
you can use to refresh the list -->
{{> MailChimpListsRefresh}}
{{> MailChimpLists}}
</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
MailChimpLists at the moment exposes the following methods both server- and client-side:
NOTE: If
callback
is ommited server-side, the method runs "synchronously" viaMeteor.wrapAsync
method.
List all mailing lists for a given API Key
params
Parameters to pass to the API method.callback
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.
Subscribe email to the list
params
Parameters to pass to the API method.callback
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.
Unsubscribe email from the list
params
Parameters to pass to the API method.callback
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.
List recipient groups for a given list
params
Parameters to pass to the API method.callback
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.
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.
List all lists for a given API Key
Refresh list of all lists for a given API Key
// You can as well pass different parameters on each call
var mailingLists = new MailChimpLists( /* apiKey, { version : '2.0' } */ );
mailingLists.list(
{ /*
filters: {
list_id: '<some_list_id>'
},
start: 0,
limit: 100,
sort_field: '',
sort_dir: '' */
},
// Callback beauty in action
function ( error, result ) {
if ( error ) {
console.error( '[MailChimpLists][List] Error: %o', error );
} else {
// Do something with your data!
console.info( '[MailChimpLists][List]: %o', result );
}
}
);
// You can as well pass different parameters on each call
var mailingLists = new MailChimpLists( /* apiKey, { version : '2.0' } */ );
var result = mailingLists.list(
{ /*
filters: {
list_id: '<some_list_id>'
},
start: 0,
limit: 100,
sort_field: '',
sort_dir: '' */
}
);
// Do something with your data!
console.info( '[MailChimpLists][Lists]:\n', JSON.stringify( result ) );
- Update to Meteor v1.0
- On client, MailChimpLists.call() now reads API Key from session variable 'MailChimp.apiKey'
- Cleanup
- On client, MailChimp.call() now reads API Key from session variable 'MailChimpOptions.apiKey' as well
- Initial release
Copyright © 2014-2015 Miroslav Hibler
miro:mailchimp-lists is licensed under the MIT license.