MailChimp API – Subscribe User Through PHP

MailChimp API

MailChimp API

This ia a Mailchimp API example using PHP and cURL.
This will helps you add more subscribers to your MailChimp lists using PHP and cURL Method.

So MailChimp let your users to susbscribe and you can send them newsletters in bulk and manage your subscriber’s lists.
Things which are required before you start code.
Sign Up on MailChimp

After successfull account creation and activation, Generate your API keys and List ID.

Go to your Account Settings -> Extras -> API Keys
Click on Create a Key button and you will have you API key ready.
After that go to Lists section, Create List, Visit your created lists under Settings -> List name & defaults you will find List ID.

Based on the List Members Instance docs, the easiest way is to use a PUT request which according to the docs either “adds a new list member or updates the member if the email already exists on the list”.

PHP CODE

MailChimp API send request through CURL so make sure you have enabled CURL in your PHP.

Using this curl method auto-subscribe a user without confirming activation URL directly.

I’m using the following function to add and update list members. You may need to include a slightly different set of merge_fields depending on your list parameters.

If you have any query or need any further explanation please do not hesitate to reply me.

You may also like

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *