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.