Jack Barber Design & Technology

01947 878108 info@jackbarber.co.uk

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
       
require('/PATH/TO/MAILCHIMP/API/FILES');
$Mailchimp = new Mailchimp( $api_key );
$subscriber = $Mailchimp->lists->subscribe($list_id, array('email' => $Email), '', false, false);

Double_Optin

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.

Easy!