MailChimp API v2 Subsribe User (PHP)

This post is old. It may contain broken links, missing images and incorrect information.

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!

Jack Barber, freelance web developer based in Whitby, UK

Written By

I'm a freelance web developer based in Whitby, UK. I built my first website using GeoCities, and learned to write HTML and CSS using Notepad. Web technology has come a long way since then, as have my web development skills!

These days I love helping my clients make the most of the internet. I provide design, development, marketing and IT support services, forming long-term partnerships with my clients.

Connect With Me

Posted in Uncategorized