Jack Barber / Website Design

MailChimp API v2 Subsribe User (PHP)

It's been a while since I did anything with the MailChimp API, and now that they've upgraded to v2 my old code snippets don't work.  Today I needed to get www.robin-hoods-bay.co.uk advertisers to be automatically subscribed to the mailing their mailing list.  Here's the code:

$api_key = "????"; //your API key - create one in your MailChimp account
$list_id = "????"; //the ID of the list you want to subscribe your user to
$Mailchimp = new Mailchimp( $api_key );
$subscriber = $Mailchimp->lists->subscribe($list_id, array('email' => $Email), '', false, false);


Because we want all the advertisers automatically subscribed without them needing to confirm their subscription I changed the double_optin variable to FALSE - this way all new registered advertisers are automatically added.