Last active
May 24, 2016 04:31
-
-
Save freshlogic/dd0ff50d927b289c7821934e52fd3c01 to your computer and use it in GitHub Desktop.
Error 212
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mcapi = require('mailchimp-api'); | |
const mailchimp = new mcapi.Mailchimp(process.env.mailchimpApiKey); | |
const mailchimpListId = process.env.mailchimpListId; | |
var subscribe = { | |
double_optin: false, | |
email: { email: '[email protected]' }, | |
id: mailchimpListId | |
}; | |
mailchimp.lists.subscribe(subscribe, (member) => { | |
var unsubscribe = { | |
email: { leid: member.leid }, | |
id: mailchimpListId | |
}; | |
mailchimp.lists.unsubscribe(unsubscribe, () => { | |
var resubscribe = { | |
email: { leid: member.leid }, | |
id: mailchimpListId | |
}; | |
mailchimp.lists.subscribe(subscribe, () => { | |
console.log('success'); | |
}, err => { | |
return console.error('resubscribe error', err); | |
}); | |
}, err => { | |
return console.error('unsubscribe error', err); | |
}); | |
}, err => { | |
return console.error('subscribe error', err); | |
}); | |
/* | |
resubscribe error { status: 'error', | |
code: 212, | |
name: 'List_InvalidUnsubMember', | |
error: '[email protected] has unsubscribed, and cannot be resubscribed by you. To prevent false spam complaints, they\'ll need to resubscribe of their own free will.' } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment