Mailchimp API V3 CodeIgniter Library Integration

By Ralph Vugts on Feb 9, 2016

Looking to quickly integrate Mailchimp API V3 with code igniter? I've taken this API wrapper and converted it into a library for CI so you can quickly integrate it into your project.

Step 1:

Download this file and add it into your application/libraries folder. On line 185 I have manually overridden the timeout value as it was always timing out when trying to pull lists from Mailchimp.

Step 2:

Add your Mailchimp API key to your config file:

$config['Mailchimp_api_key'] = 'YOUR_KEY_HERE';

Step 3:

Load the library into your controller and add the ID of the list you would like to add a contact to. Eg:

Load the library:

$this->load->library('MailChimp');

Add the appropriate list id:

$list_id = 'YOUR_LIST_ID';

Make the API call:

$result = $this->mailchimp->post("lists/$list_id/members", [
'email_address' => 'persons_email@gmail.com',
'merge_fields' => ['FNAME'=>'Ralph', 'LNAME'=>'Vugts'],
'status' => 'subscribed',
]);

Check out the full git repo for more info on other functions.

Need help integrating Mailchimp into your existing website? We can help you! Get in touch and let just know what you are trying to achieve.

Ralph has been developing websites and systems for nearly 20 years. Passionate and curious, he’s an a-typical developer who understands how users interact with the systems he builds. He understands that systems need to be human-friendly. Ralph loves working in an industry that is constantly changing and disrupting itself.

Get in touch, We love to talk