Log in to your A2 Hosting account using SSH.
At the command prompt, type the following commands:
cd ~
git clone https:
After the git clone command completes, there is a new mailchimp-api-php directory.
Type the following command:
cp -R mailchimp-api-php/src mailchimp
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:
<?php
require('mailchimp/Mailchimp.php');
$api_key = "Add your Mailchimp API key here";
$list_id = "Add your list ID here";
$Mailchimp = new Mailchimp( $api_key );
$Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp );
try
{
$subscriber = $Mailchimp_Lists->subscribe(
$list_id,
array('email' => 'kellykoe@example.com'),
array('FNAME' => 'Kelly', 'LNAME' => 'Koe'),
'text',
FALSE,
TRUE
);
}
catch (Exception $e)
{
echo "Caught exception: " . $e;
}
if ( ! empty($subscriber['leid']) )
{
echo "Subscriber added successfully.";
}
else
{
echo "Subscriber add attempt failed.";
}
?>