Mailchimp API V3 CodeIgniter Library Integration
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.
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.
Add your Mailchimp API key to your config file:
$config['Mailchimp_api_key'] = 'YOUR_KEY_HERE';
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:
Add the appropriate list id:
$list_id = 'YOUR_LIST_ID';
Make the API call:
$result = $this->mailchimp->post("lists/$list_id/members", [ 'email_address' => '[email protected]', '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.