Home > CMS- Content Management System > Joomla > Integrate the Mailchimp API with your PHP application

Integrate the Mailchimp API with your PHP application

The API docs can be found here.

In this article we will take a quick look at how to integrate this with your PHP application. If you want a detailed reference on integration then its better to look at the official API documentation. Here, we just want to give a simple and practical explanation on how to go about it.

INTEGRATION ASPECTS

At the very basic level, integration deals with only two things:

  1. Subscribers
  2. Newsletters

HANDLE SUBSCRIBERS

First get your API Key. To do this you need to signup. Check this URL

Once you have obtained the API key, put in a config file which can be included in your page. eg. config.inc.php

 Design your HTML form. At the very least you will need an email id field to capture. Apart from this you can use Merge Tags to add into your code.

If you want to implement the code using AJAX/Javascript then you need to plan the callbacks. Otherwise setup a simple form to submit to a PHP script that implements the listSubscribe() API call

The sample code is shown below:

 Once a member has been subscribed, if you want to add this in your website database. you can do so and store the member mailchimp id for synchronisation by calling a method called listMemberInfo() . The sample code is shown below: 

 CREATE CAMPAIGNS TO SEND NEWSLETTERS

Each newsletter that you want to send is done by creating a campaign. The sample code to create a campaign is below:

Create a campaign for a future date

 Create a campaign to send immediately

UNSUBSCRIBE A MEMBER

To unsubscribe a member from a campaign, use the sample code below:

 

DELETE A CAMPAIGN

Lastly if you want to delete a campaign the code is shown below:

This Article is TAGGED in , , . BOOKMARK THE permalink.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">