How to use the MailChimp API with PHP
https://www.a2hosting.com/kb/developer-corner/php/using-the-mailchimp-api-with-php
How to use the MailChimp API with PHP
This article discusses how to use the MailChimp API (application programming interface) with PHP.
This article assumes that you have already signed up for and configured a MailChimp account. For information about how to do this, please see this article.
About the MailChimp API
The MailChimp API (application programming interface) provides a way to work with campaigns and lists programmatically. This article demonstrates various ways to use the API with PHP.
Using the official API wrapper
To access your MailChimp account using PHP, you use code that provides a “wrapper” to the API. There are several unofficial API wrappers for MailChimp that use a simplified interface. The procedure below, however, demonstrates how to use the official MailChimp API wrapper.
To do this, follow these steps:
Log in to your A2 Hosting account using SSH.
At the command prompt, type the following commands:
After the git clone command completes, there is a new mailchimp-api-php directory.
Type the following command:
This command copies the API source code to the separate mailchimp directory (you can actually use any directory name you want). Doing so enables you to pull future updates in the mailchimp-api-php directory for further testing, without overwriting source code referenced directly by your applications.
To use the MailChimp API in your PHP code, you must include the Mailchimp.php file. Then you can create a Mailchimp object and work with the API. For example, the following code sample demonstrates how to add a new subscriber to an existing list:
More Information
For more information about the MailChimp API, please visit https://apidocs.mailchimp.com.
Last updated